SpringBoot中,yml无法识别@符号
问题:application.yaml文件读取不到pom.xml下的标签值,报
Caused by: org.yaml.snakeyaml.scanner.ScannerException: while scanning for the next token
found character ‘@’ that cannot start any token. (Do not use @ for indentation)
in ‘reader’, line 7, column 13:
active: @spring.profiles.active@
的解决方法 :
在pom文件中写入以下代码
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
这段代码是用来配置 Maven 项目构建过程中资源文件的处理方式的。具体来说:
<directory>src/main/resources</directory>
指定了资源文件的目录为src/main/resources
,这是 Maven 项目中存放资源文件的默认目录。<filtering>true</filtering>
表示开启资源文件的过滤功能。当设置为true
时,Maven会在资源文件中查找${...}
形式的占位符,并根据项目中的属性值替换这些占位符。这样可以实现动态替换配置文件中的变量值,比如替换版本号、环境变量等。
原文链接:https://blog.youkuaiyun.com/a1513049385/article/details/114280579