美文网首页
Spring Boot 01

Spring Boot 01

作者: lhl_012 | 来源:发表于2017-05-10 17:58 被阅读18次

    官网:http://projects.spring.io/spring-boot/
    1.配置pom.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.example</groupId>
    <artifactId>myproject</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.4.0.RELEASE</version>
    </parent>
    <dependencies>
    <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    </dependencies>
    </project>
    2.写Hellow World


    @SpringBootApplication
    @RestController
    public class Application {

    @RequestMapping("/")
    public String greeting() {
        return "Hello World!";
    }
    
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
    

    }

    3.运行
    由于我们使用了 spring-boot-starter-parent POM,所以可以使用 mvn spring-boot:run 启动
    <build>
    <plugins>
    <plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    </plugin>
    </plugins>
    </build>
    mvn package,打包jar到/target目录下

    java -jar target/myproject-0.0.1-SNAPSHOT.jar 运行jar

    相关文章

      网友评论

          本文标题:Spring Boot 01

          本文链接:https://www.haomeiwen.com/subject/qomgtxtx.html