Spring 使用maven构建时选择弹簧轮廓
我试图为我的生产环境创建一个构建。在我的SpringWeb应用程序中,我有4个.yml文件Spring 使用maven构建时选择弹簧轮廓,spring,maven,spring-boot,Spring,Maven,Spring Boot,我试图为我的生产环境创建一个构建。在我的SpringWeb应用程序中,我有4个.yml文件 application.yml application-development.yml application-staging.yml application-production.yml 在application.yml文件中,我指定了 spring: profiles: active: production 我使用maven创建构建的命令是 mvn clean install tomca
spring:
profiles:
active: production
我使用maven创建构建的命令是
mvn clean install tomcat7:deploy -B -Pproduction
在我的目标文件夹中,我可以在not up中查看所有属性和我的生产设置
我得到的是默认的application.yml属性。如何正确构建?在您的application.yml中,添加如下内容:
spring:
profiles:
active: @active-profiles@
然后尝试:
mvn clean install tomcat7:deploy -B -P production
在pom.xml中(在mvn命令-生产过程中传递maven配置文件,该配置文件查找属性并替换应用程序.yaml中的属性,由spring boot starter父级中内置的spring boot maven插件替换)
org.springframework.boot
您不应该为环境创建特定的构建。您将传递1个构建。在启动应用程序时,您指定要激活的配置文件。考虑查看Spring云配置,以方便地管理每一个环境中的特定配置。@ M.DENIN在Tomcat $TomCCATHOME/BIN/SETENV.SH中,我添加了这个选项,输出Calalina AOPTS =“$CATALINA_OPTS-Dspring.profiles.active=生产,但它也不工作。我正在将war移动到已在运行的tomcat实例。我是否需要执行其他操作?无法添加active:@active。profiles@.it正在显示错误我添加了更详细的答案。我假设您已经配置了maven配置文件。请查看以下内容以了解更多信息:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.2.RELEASE</version>
<relativePath />
</parent>
.
.//Dependencies go here
.
<profiles>
<profile>
<id>production</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<properties>
<active-profiles>production</active-profiles>
</properties>
</profile>
</profiles>