使用springboot默認創建項目,是application.properties,改成yml格式時,需要注意以下幾點:
- 注釋中不能用中文
- yml格式,采用tree形狀,key和value中的“冒號",冒號與值之間要有空格,如 username: root
- 同一級別節點格式要對齊,下面紅包部分由於沒有對齊,運行項目時報錯
spring: datasource: url: jdbc:mysql://127.0.0.1:3306/business?useUnicode=true&characterEncoding=utf-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC username: root password: root driverClassName: com.mysql.cj.jdbc.Driver # use mysql jpa: database: mysql # is show sql show-sql: true mybatis: typeAliasesPackage: com.xj.demo.model mapper-locations: classpath:mapper/*.xml # JWT Object save audience audience: clientId: 098f6bcd4621d373cade4e832627b4f6 # A key that can be replaced by Base64 encryption base64Secret: MDk4ZjZiY2Q0NjIxZDM3M2NhZGU0ZTgzMjYyN2I0ZjY= # The issuing subject of the JWT shall be deposited in the issuer name: springbootapi # Expired 24 hours expiresSecond: 86400 pagehelper: helperDialect: mysql reasonable: true # To minimize or maximize the number of pages when the input page is negative or larger supportMethodsArguments: true params: count:countSql
yml中格式錯誤,肉眼不太容易找出錯誤,推薦一個在線查看的工具:http://old.qqe2.com/jsontool/yaml.php
修改正確后的效果