SpringBoot 运行时提示'No active profile set, falling back to 1 default profile: 'default'' 解决方法
您在打包时将 application-prod.properties 打包到了 target 目录下,但是仍然提示没有激活 prod 环境配置,这可能是因为您没有在启动类上使用 @ActiveProfiles 注解明确指定激活的环境。
您需要在您的启动类上标注 @ActiveProfiles('prod'),以激活您的 prod 环境配置。例如:
@SpringBootApplication
@ActiveProfiles('prod')
public class MyApplication {
public static void main(String[] args) {
SpringApplication.run(MyApplication.class, args);
}
}
这将激活您的 prod profile,并且您应该可以看到 application-prod.properties 文件被正确加载。
原文地址: https://www.cveoy.top/t/topic/lPVh 著作权归作者所有。请勿转载和采集!