为了账号安全,请及时绑定邮箱和手机立即绑定

为什么我在application.yml里面的mysql配置没有生效

spring:
  profiles:
    active: dev
  datasource:
    driver-class-name: com.mysql.jdbc.Driver
    url: jdbc:mysql://127.0.0.1:3306/dbgirl
    username: root
    password: root
  jpa:
    hibernate:
      ddl-auto: create
    show-sql: true

这个配置没有给数据库生效,但是项目也能运行也没报错

正在回答

1 回答

看看你的spring-boot版本和MySQL版本,不同版本可能写法不同。

我用的是spring-boot版本是2.0.5,MySQL是57,写出来这样的

https://img1.sycdn.imooc.com//5bb0903f000154dd06210348.jpg

还有这个类的Id注解用的是这个包

https://img1.sycdn.imooc.com//5bb090a5000181e705990389.jpg

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
2小时学会Spring Boot
  • 参与学习       151655    人
  • 解答问题       1079    个

Spring Boot入门视频教程,你将学会使用Spring Boot快速构建应用程序

进入课程

为什么我在application.yml里面的mysql配置没有生效

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信