记录一次Springboot项目打包后运行出现’url’ attribute is not specified and no embedded datasource could be configured
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.properties</include>
</includes>
</resource>
</resources>
</build>
然后打包jar,运行后又发现,虽然成功运行,但是访问什么页面都是
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Tue Jan 11 21:56:31 CST 2022
There was an unexpected error (type=Not Found, status=404).
最后发现我的项目下的resources下放着我所有的静态文件static,但是上面代码说的<includes><include>**/*.properties</include></includes>
则表示仅打包这个类型的文件,所以访问资源的时候就会出现上图这种的情况
此时我们只需要把这些静态文件打包进去
<resource>
<directory>src/main/resources</directory>
<includes>
<include>static/**</include>
<include>**/*.properties</include>
</includes>
</resource>
或
<resource>
<directory>src/main/resources</directory>
</resource>
参考文章
https://www.hangge.com/blog/cache/detail_2887.html
https://www.cnblogs.com/wangxuchun/p/7501719.html
https://blog.csdn.net/gaoyipingzgh000/article/details/109600530