记录遇到的一个springboot项目启动错误‘url‘ attribute is not specified

博客作者遇到了SpringBoot应用启动时的数据源配置错误,尝试了多种解决方案,如排除DataSourceAutoConfiguration、修改配置文件等,但问题仍未解决。最终发现是由于编码不一致导致,通过添加启动参数-Dfile.encoding=utf-8成功启动了应用。
摘要由CSDN通过智能技术生成

        今天在启动一个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

        从字面上看来象是一个很简单的数据库配置参数错误,可是反复检查pom,properties,yml等地方都是正确的,有网友说是driver-class-name驱动版本不一致、或是在启动类的@SpringBootApplication加上@SpringBootApplication(exclude={DataSourceAutoConfiguration.class}),或是修改配置如:

spring:
    autoconfigure:
    exclude:  com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure #去除druid配置

        以上经尝试均未解决,那么换个思路,这个项目之前一直就是可以正常运行的,难道又是常见的编码不一致引起的?于是加上启动参数-Dfile.encoding=utf-8如下:

        java -Dfile.encoding=utf-8 -jar xxx.jar &

        just as expected,正常启动了...

        祝好!

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值