spring:
  profiles:
    active: @spring.profiles.active@

pom.xml 配合 yaml 文件实现动态配置。

项目使用了如上配置,一开始可以运行。但是在某次运行时突然开始报错。

Exception in thread "main" while scanning for the next token
found character '@' that cannot start any token. (Do not use @ for indentation)
 in 'reader', line 3, column 13:
        name: @spring.profiles.active@

解决方案是先检查是否在 maven 构建时选择了相应的配置。如果不能解决问题,则在 @@ 两侧加上单引号 ' 或双引号 "

spring:
  profiles:
    active: '@spring.profiles.active@'
Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐