我的Spring运行配置只是带有以下VM选项的默认设置:
-Dspring.profiles.active=local
我的Maven运行配置是默认设置,命令行中包含以下内容:
spring-boot:run
以及VM选项中的以下内容:
-Dspring.profiles.active=local
当我运行Maven时,它不会出现在配置文件中,而是使用默认值:
No active profile set, falling back to default profiles: default
使用Spring配置时,我没有任何问题,问题在于我需要如何部署它,它使用了maven命令,因此我不会失败,而且我也不十分了解为什么会发生这种情况。这个项目真的没有什么花哨的。这是您的基本微服务。
以防万一。根“应用程序”文件仅具有以下内容:
@SpringBootApplication
public class MyApplication {
public static void main(String[] args) {
SpringApplication.run(MyApplication.class, args);
}
}
链接到Maven运行配置。这是所有默认值,如图所示。 https://imgur.com/a/GGiwimQ
答案 0 :(得分:1)
在命令行参数中添加以下内容似乎可以解决此问题:
-Drun.jvmArguments=-Dspring.profiles.active=local
尽管我知道它为什么起作用,但并不能解释为什么这首先发生。如果我找出真正的原因,我将更新此答案。
答案 1 :(得分:-1)
创建
application.properties
src / main / resources中的文件(如果不存在)并添加
spring.profiles.active=local