7

SpringBoot 工程 Run/Debug 时报错:active: @profile.name@ 相关的 @ 不识别

 1 year ago
source link: http://www.blogjava.net/welldoer/archive/2023/08/29/451185.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

SpringBoot 工程 Run/Debug 时报错:active: @profile.name@ 相关的 @ 不识别

现象:
1、此工程之前实际正常 Run/Debug 过,每次修改代码会在 idea 中重新 package 打包;
2、偶然执行 Run/Debug 均报告 active: @profile.name@ 相关的错误信息,重新打包后依然报错;

分析及解决:
1、基于 active: @profile.name@ 及启动日志信息,明确 springboot 启用了 @...@ 动态获取配置的意图;
2、检查 idea 中 maven 插件,确保有选中合适的 profile 选项(有必要到根 pom.xml 中检查对应项);
 2.a、若多选 maven 插件中的多个 profile 选项,则会按 pom.xml 中物理可用的最后一个来处理;
 2.b、若全部不选、多选但全部没有对应项,则 @profile.name@ 无法被动态转译,进而保留不变;
3、在 maven 插件中选择 compile/package,随后 target/classes/application.yml 中查看结果;

参考:
1、while scanning for the next tokenfound character ‘@‘ that cannot start any token.
2、聊聊 SpringBoot 中的两种占位符:@*@ 和 ${*}
3、在构建时期自动扩展info属性
4、SpringBoot配置文件
5、Spring Boot中YAML属性配置文件使用详解
6、Spring boot2 使用profile 配置多环境
7、Could not resolve placeholder ‘xxx‘ in value “${xxx}“

posted on 2023-08-29 17:18 快车道 阅读(4) 评论(0)  编辑  收藏


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK