spring boot初学者
初学spring boot,留自己的初学经理。
首先spring boot 的具有一些特点,
A:首先spring boot 创建独立的spring应用程序。
B:嵌入tomcat等web容器,无需war包来部署。
C:简化maven的开发配置。简单易学。
D:自动配置spring,简化spring的开发流程。
E:提供生产就绪型功能,如指标,健康检查和外部配置。
F:绝对没有代码生成和对XML没有要求配置
下面我们来搭建第一个spring boot 应用
pom.xml
<!-- Inherit defaults from Spring Boot -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.3.RELEASE</version>
</parent>
<!-- Add typical dependencies for a web application -->
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
java 代码
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
@RestController
@EnableAutoConfiguration
public class BaseController {
@RequestMapping("/hello")
@ResponseBody
String home() {
return "Hello ,spring boot!";
}
public static void main(String[] args) throws Exception {
SpringApplication.run(BaseController.class, args);
}
}
这样我们一个简单的spring boot 应用就搭建好了