新搭建的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
...全文
12089 3 收藏 6
写回复
6 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
karaysn 2020-01-24
4楼帮助我解决了,感谢。
回复
Vincent_sv 2019-09-07
解决问题方法,如果你需要用到数据库组件,那么就需要配置一下数据源相关的信息;如果暂时不需要数据库组件,那么可以在项目启动类上,这样写@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})就可以了;或者就是注释掉pom文件中用到的数据库相关starter组件引入,重新更新一下maven项目依赖也可以。
回复
是用idea弄的吗,如果是看看pom文件里面 有没有打包成pom,有的话去掉
回复
jx2956 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
对了
回复
两个猕猴桃 2018-06-22
应该是找不到mysql的驱动,把mysql驱动的依赖加进去。
回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2018-06-22 06:25
社区公告
暂无公告