[已解决] application run failed org.yaml.snakeyaml.scanner.ScannerException
解决:application run failed 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', lin
问题
运行spring boot项目,遇到下面的错误:
application run failed 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 4, column 13: active: @profiles.active@
分析
打包后的文件里,application.yml文件里的@profiles.active@,没有被替换成具体的环境值,如dev等。
重点:确保yml文件内容格式没有书写错误。如下案例:
案例
application.yml文件键值之间要用冒号:隔开,而且冒号和值之间有一个空格,否则就报上面的错误!
错误写法:
enableWebDubug:true
正确写法:
enableWebDubug: true
解决
修改项目的pom文件,添加profiles,同时制定默认激活的profile,如下所示,激活dev环境:
<profiles>
<!-- 开发环境 -->
<profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<profiles.active>dev</profiles.active>
<profiles.logFile>/home/logs/xxx.log</profiles.logFile>
</properties>
</profile>
<!-- 功能测试环境 -->
<profile>
<id>test</id>
<properties>
<profiles.active>test</profiles.active>
<profiles.logFile>/home/logs/xxx.log</profiles.logFile>
</properties>
</profile>
<!-- 生产环境 -->
<profile>
<id>prod</id>
<properties>
<profiles.active>prod</profiles.active>
<profiles.logFile>/home/logs/xxx.log</profiles.logFile>
</properties>
</profile>
</profiles>
更多推荐



所有评论(0)