Spring boot 搭建

1、pom文件引入:

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.4.RELEASE</version>
    </parent>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>

2、创建spring boot 启动类

@SpringBootApplication // Spring Boot核心注解,用于开启自动配置
public class DemoApplication extends SpringBootServletInitializer{

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }
}

3、添加测试controller

@RestController
public class TestController {

    @RequestMapping("/query")
    public String query() {
        return "hello Spring boot!";
    }
}

4、注意事项

controller必须和DemoApplication 在同一个包下或者与DemoApplication 同级的子包下。

暂时写这么多,后续有添加的再补充。

posted @ 2018-09-19 23:09  熊掌和鱼  阅读(122)  评论(0)    收藏  举报