1 springboot 特性
-
创建独立的Spring应用程序
-
直接嵌入Tomcat,Jetty或Undertow(无需部署WAR文件)
-
提供自以为是的“入门”依赖项以简化构建配置
-
尽可能自动配置Spring和第三方库
-
提供生产就绪功能,例如指标,运行状况检查和外部化配置
-
绝对没有代码生成,也不需要XML配置
2 springboot 框架搭建
在pom.xml 中配置maven 依赖
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.3.RELEASE</version>
<relativePath/>
</parent>
<!-- Add typical dependencies for a web application -->
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
2 在代码最外层所在包的同文件夹目录下创建启动类
@RestController @EnableAutoConfiguration public class SpringbootdemoApplication { @RequestMapping("/") String home() { return "Hello World!"; } public static void main(String[] args) { SpringApplication.run(SpringbootdemoApplication.class, args); } }
3 启动项目