一般的springboot项目会有application.yml或者application.properties文件,开发中需要连接数据库时密码可能会有特殊字符,.properties文件不会报错,但是.yml文件会报错。
解决:yml中password对应的值用单引号引住('!@test')就可以了,如下
spring:
datasource:
password: '!@test'
type: com.alibaba.druid.pool.DruidDataSource
url: jdbc:mysql://localhost:3306/test?characterEncoding=utf-8
username: root
本文介绍在SpringBoot项目中使用YAML配置文件时如何正确设置包含特殊字符的数据库密码,以避免语法错误。
5576





