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




 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM