springboot报错Failed to configure a DataSource url attribute is not specified and no embedd

Failed to configure a DataSource: ‘url’ attribute is not specified and no embedded datasource could be configured.在初步搭建springboot应用,因为没有进行数据库配置,如地址值,数据库驱动,用户名,密码等,常常会出现上述错误,表示是无法配置DataSource:未指定‘URL’属性,无法配置嵌入数据源。

Springboot最大的一个好处就是自动配置,所以我们只需要配置相关属性的值,它就会自动配置,配置在application.properties文件中。

#访问根路径

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

#访问端口号
server.port=8080

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

#数据库相关配置
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/stxcx
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

当然,如果此时你还不想配置,你也可以声明一下
启动类头部声明:

@SpringBootApplication(exclude= {DataSourceAutoConfiguration.class})

感谢观看,如果有帮到小伙伴,请点赞哦!!!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值