spring boot-01 认识spring boot和入门程序
认识spring boot :
特性:
-
Create stand-alone Spring applications Embed Tomcat, Jetty or Undertow directly (no need to deploy WAR files) Provide opinionated starter dependencies to simplify your build configuration Automatically configure Spring and 3rd party libraries whenever possible Provide production-ready features such as metrics, health checks, and externalized configuration Absolutely no code generation and no requirement for XML configuration
独立的标准的spring应用
嵌入tomcat jetty 或者 Undertow directly ,不需要部署war包
提供可选的启动器依赖简化配置--例如,这个依赖替代了之前springmvc的配置。
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency>
尽可能自动配置spring 和第三方
提供可用于生产的特性,度量标准,健康检查,外部化配置
不需要生成代码和xml配置
入门程序
-
方式一
从spring网站创建
创建之后,下载到本地。
下载的压缩包可以直接导入idea。这就是一个完整的maven项目工程。
在main入口同级文件包下就可以自定义一个controller
HellowController
package springboot.springboothello.controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController public class HellowController { @RequestMapping("/hello") public String testHellow(){ return "Hello springboot."; } }
重启容器,就可以通过url访问了:
-
方式二
idea直接创建
后面的步骤和之前类似
上一篇:
IDEA上Java项目控制台中文乱码