‘url‘ attribute is not specified and no embedded datasource could be configured.

记录一次Springboot项目打包后运行出现’url’ attribute is not specified and no embedded datasource could be configured

问题描述
Springboot项目打包成jar,运行后出现如下描述的问题

Description:
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine a suitable driver class

看似是没有找到url信息,实际上是没有找到properties文件
去pom.xml文件中手动配置一下

<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

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值