問題
springboot項目報錯:
java.lang.IllegalStateException: Failed to load property source from location 'classpath:/application.yml'
原因及辦法
- 項目的application-dev.yml,編碼有問題,在idea的setting中設置如下
- 可能是你的application.yml文件中有utf-8編碼後的註解,把註解全部刪除即可
spring:
datasource:
username: root
password: root
url: jdbc:mysql://localhost:3306/flutter
driver-class-name: com.mysql.jdbc.Driver
type: com.alibaba.druid.pool.DruidDataSource
initialSize: 5
minIdle: 5
maxActive: 20
maxWait: 60000
timeBetweenEvictionRunsMillis: 60000
minEvictableIdleTimeMillis: 300000
validationQuery: SELECT 1 FROM DUAL
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
poolPreparedStatements: true
filters: stat,wall,log4j
maxPoolPreparedStatementPerConnectionSize: 20
useGlobalDataSourceStat: true
connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=500
mybatis:
mapper-locations: classpath*:com/example/demo/mapper/*.xml
type-aliases-package: com/example/demo/beans/*
注意:
上面步驟執行完,把target編譯文件刪掉,重新運行編譯