springboot 学习历程
添加功能
idea 下配置热部署启动
- 按下快捷键 ctrl shift alt / 选中 complier.automake.allow.wher.app.running在后面打勾
- pom文件配置
<dependencies>
... ...
<!--devtools热部署-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
<scope>true</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
</configuration>
</plugin>
</plugins>
</build>
- 配置application.yml
- idea打开设置setting-build 在build project automaticlly
- 最后一步,idea配置maven启动
配置启动项
添加启动命令 spring-boot:run
最终热部署就搞定啦
遇到的bug
controller访问任何接口404
解决方案
- 缺少包扫描 @ComponentScan 注解,添加该注解,注解中填controller所在的包路径 com.xxx.controller
- 将启动类Application 放到其他包路径的最外层,Application启动将会扫描其所在的包下面的类