idea下springboot 项目在static目录下添加文件不生效

idea下springboot 项目在static目录下添加文件不生效

问题描述
是这样子的,我的项目目录结构如下:
《idea下springboot 项目在static目录下添加文件不生效》
我在static目录下,创建了index.html和aaaa.jpg这两个文件。然后,启动服务访问 http://loclahost:8080/
可以正常访问
《idea下springboot 项目在static目录下添加文件不生效》
现在,有我创建test目录,添加这两个文件。目录如下:
《idea下springboot 项目在static目录下添加文件不生效》
现在,我重启服务,访问 http://localhost:8080/test/aaaa.jpg 出现404
《idea下springboot 项目在static目录下添加文件不生效》

打开target目录如下
《idea下springboot 项目在static目录下添加文件不生效》
可以看到静态static下没有test目录。所以,404很正常。

解决办法,在pom文件添加build如下:

《idea下springboot 项目在static目录下添加文件不生效》
删除,再添加文件,重启服务。页面可以访问了。

有问题,请留言!

个人博客地址: https://blog.ailijie.top/arch…

    原文作者:wotrd
    原文地址: https://segmentfault.com/a/1190000019795082
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞