一:springboot 快速开始
1、先把maven的配置文件设置为如下配置
jdk‐1.8
true
1.8
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
2、配置IDE的环境(maven配置)
3、创建一个空的maven工程,然后导入springboot相关的jar包
//父工程依赖
org.springframework.boot
spring-boot-starter-parent
2.0.8.RELEASE
spring mvc-web的依赖
org.springframework.boot
spring-boot-starter-web
4、
(1)编写主入口程序
@SpringBootApplication
public class TulingStartMain {
public static void main(String[] args) {
SpringApplication.run(TulingStartMain.class,args);
}
}
(2)其他业务组件 比如controller service repository compent注解标示的组件
自己写的组件必须放在主启动类(TulingStartMain)在所包的及其子包下
@RestController
public class TulingController {
@RequestMapping("/tuling")
public String tulingHelloWorld() {
return “tuling,hello”;
}
}
(3)运行main函数启动程序,访问 http://localhost:8080/ tuling,或者执行mvn package将项目打成jar包,用java -jar XXX.jar直接运行
通过idea创建 一个springboot项目
(1)
(2)helloworld的探究,为啥我只要引入 spring-boot-starter-parent 和 spring-boot-starter-web就可以快速开发mvc的项目,pom分析
org.springframework.boot
spring-boot-starter-parent
2.0.8.RELEASE
真正的版本管理中心, 来决定应用的版本
org.springframework.boot
spring-boot-dependencies
2.0.8.RELEASE
…/…/spring-boot-dependencies
以后我们导入依赖默认是不需要写版本;(没有在dependencies里面管理的依赖自然需要声明版本号)