问题
使用sprinboot+thymeleaf,前后端不分离,一个功能是用户可以上传图片,之后可以在网页展示。用户上传的图片能在对应的静态资源目录中找到,但是在target目录没有,导致无法显示在前端界面
解决
配置热部署
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
之后更改idea的配置项
- 配置 IDE 支持:在 IntelliJ IDEA 中,确保
File -> Settings -> Build, Execution, Deployment -> Compiler
下的Build project automatically
选项已勾选。 - 触发自动构建:按下
Ctrl + Shift + Alt + /
,选择Registry
,然后找到并勾选compiler.automake.allow.when.app.running
。
之后添加完刷新一下网页就能显示了