新搭建的SpringBoot项目,启动报错Failed to determine suitable jdbc url

本文介绍了SpringBoot项目启动时遇到的`Failed to auto-configure a DataSource`错误,原因是缺少数据库驱动配置。解决方案包括在pom.xml中添加MySQL驱动依赖、检查资源配置以及排除DataSource自动配置。同时提供了在IDEA中排查pom文件是否正确打包的建议,以及通过注解排除数据源自动配置的临时解决办法。
摘要由CSDN通过智能技术生成

项目启动类

@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class}) 
@SpringBootApplication
public class JinlongSystemWebApplication {

public static void main(String[] args) {
SpringApplication.run(JinlongSystemWebApplication.class, args);
}
}

application.properties配置

server:
   port: 8090
spring:
application:
name: jinlong-system
datasource:
type: com.alibaba.druid.pool.DuridDataSource
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost:3306/jinlong?useUnicode=true&characterEncoding=utf-8
username: root
password: 
mybatis:
mapper-locations: classpath:mybatis/mapper/*/*.xml

启动报错:

Failed to auto-configure a DataSource: 'spring.datasource.url' is not specified and no embedded datasource could be auto-co

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值