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

u011013470 2018-06-22 06:25:10
项目启动类

@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-configured.

Reason: Failed to determine suitable jdbc url


Action:

Consider the following:
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
If you have database settings to be loaded from a partic
...全文
15763 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
karaysn 2020-01-24
  • 打赏
  • 举报
回复
4楼帮助我解决了,感谢。
Vincent_sv 2019-09-07
  • 打赏
  • 举报
回复
解决问题方法,如果你需要用到数据库组件,那么就需要配置一下数据源相关的信息;如果暂时不需要数据库组件,那么可以在项目启动类上,这样写@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})就可以了;或者就是注释掉pom文件中用到的数据库相关starter组件引入,重新更新一下maven项目依赖也可以。
等待鲜花盛开 2019-05-16
  • 打赏
  • 举报
回复
是用idea弄的吗,如果是看看pom文件里面 有没有打包成pom,有的话去掉
jx静心 2019-04-25
  • 打赏
  • 举报
回复
有可能是没有加截到配置文件,可以尝试在pom.xml文件的build标签中加入如下内容
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.yml</include>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.yml</include>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
bj_wangZH 2019-01-08
  • 打赏
  • 举报
回复
对了
stacksoverflow 2018-06-22
  • 打赏
  • 举报
回复
应该是找不到mysql的驱动,把mysql驱动的依赖加进去。

81,122

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧