0
点赞
收藏
分享

微信扫一扫

【springboot启动报错】Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded

忍禁 2022-09-14 阅读 189


一、启动SpringBoot官方demo报错

***************************
APPLICATION FAILED TO START
***************************

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


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 particular profile you may need to activate it (no profiles are currently active).

二、问题原因

没有配置spring.datasource

三、问题解决

方法1:

#应用名称
spring.application.name=spring-boot-study

#访问端口号
server.port=8080

#编码格式
server.tomcat.uri-encoding=utf-8

#数据库相关配置
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/mysql
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.max-idle=10
spring.datasource.max-wait=10000
spring.datasource.min-idle=5
spring.datasource.initial-size=5

#session生命周期
server.servlet.session.timeout=30m

方法2:  
 

@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})

 

举报

相关推荐

0 条评论