springboot无法启动,报错Failed to configure a DataSource: 'url' attribute is not specified and no embedd

解决办法:

1在pom.xml中将多余的jar干掉,我这里就是干掉之后就能启动

 

 2如果你不想干掉多余的jar,找到启动类,在springbootApplication的注解中加入@SpringBootApplication(exclude= {DataSourceAutoConfiguration.class}),忽略配置,也可以启动

 

 3去在application.properties中配置数据库的配置,这里将一些基础配置列出来,自己按需求配置,配置好了也可以启动

#访问根路径

#应用名称
spring.application.name=springboot-demo

#访问端口号
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/sql_test
spring.datasource.username=root
spring.datasource.password=123456
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




 

posted @ 2020-08-25 11:51  我是一只老白兔  阅读(1252)  评论(0编辑  收藏  举报