spring boot 配置文件(yml)的一个坑。(mmp)

在这之前都好,启动springboot时出现:

Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2019-04-03 23:12:23.921 ERROR 34468 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

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

Description:

Cannot determine embedded database driver class for database type NONE

Action:

If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).

 这个问题很久之前就遇到过了,原因是我没有导入mysql的驱动,于是去maven依赖看了看,很明显,不是依赖的问题,瞬间懵逼,开始不停的百度,但遗憾的是,无非就是缺少jar包或者是pom里面多引入了数据库相关的包,完全和我的情况不搭边,

绝望之余,黄天不负有心人,看到了一大佬的文章(https://blog.csdn.net/mzh1992/article/details/53931267),拯救了我,原来是我的配置文件有问题

这是报错的yml文件:

server:
  port: 80
  
spring:
  datasource:
    type:com.alibaba.druid.pool.DruidDataSource
    url:jdbc:mysql://localhost:3306/myblog?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&useSSL=true
    username:root
    password:'*123456'
    driver-class-name:com.mysql.jdbc.Driver
    
  thymeleaf:
      prefix: classpath:/templates/
      check-template-location: true
      suffix: .html
      encoding: utf8
      cache: false
  mvc:
    static-path-pattern: /**
      
mybatis:
  mapper-locations:classpath:mapper/*.xml
  type-aliases-package:monsterCry.blog.model


      
这是不报错的yml文件

server:
  port: 80
  
spring:
  datasource:
    type: com.alibaba.druid.pool.DruidDataSource
    url:jdbc: mysql://localhost:3306/myblog?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&useSSL=true
    username: root
    password: '*123456'
    driver-class-name: com.mysql.jdbc.Driver
    
  thymeleaf:
      prefix: classpath:/templates/
      check-template-location: true
      suffix: .html
      encoding: utf8
      cache: false
  mvc:
    static-path-pattern: /**
      
mybatis:
  mapper-locations:classpath:mapper/*.xml
  type-aliases-package:monsterCry.blog.model


      
 乍一看是没有什么区别的,细看你会发现

多了空格。搞半天原来是空格惹的祸,令人哭笑不得,另外我发现,在同一目录的几个子项目必须格式一致,不然会解析错误。

最后我想说,这yml文件,大家还是弄个插件编写吧,不然会崩溃的。 

转载于:https://my.oschina.net/marner/blog/3032183

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值