版权声明: https://blog.csdn.net/Geroge_lmx/article/details/85335879
1.开发环境:(JDK1.8、Maven、Intelij IEDA)
- Maven:Jar包的搬运工,为我们搜集了所有Jar包;通过pom.xml文件引入Jar包依赖;
- Spring Boot:框架的搬运工,为我们整合了所有的框架;
2.工具辅助创建(脚手架)
- https://start.spring.io/
- IEDA:spring Initializr
3.pom.xml添加Spring Boot依赖
- spring-boot-maven-plugin //Spring Boot的编译插件
- spring-boot-start-web //包含了spring web mvc和tomcat等web开发的特性
- spring-boot-start-parent
4.编写启动类
- @SpringBootApplication ---> 等价于以默认属性使用@Configuration @EnableAutoConfiguration @ComponentScan
- @RestController @RequestMapping("/") ----> RestController返回Json字符串数据,直接可以编写RESTFull的接口
5.运行程序(支持热部署)
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional> <!-- 这个需要为 true 热部署才有效 -->
</dependency>
修改代码后,必须重新自动编译,才可以支持热部署,InteliJ IEDA默认关闭了自动编译,可按如下方式打开:
- IDEA启动自动编译:Settings...----Build,Execut,Deployment ----Compiler勾选Build Project automatically
- IDEA开启运行时自动make:ctrl + shift +a----搜索registry----勾选compiler.automake.allow.when.app.running