通过Maven构建中的Spring配置文件
我通过传递如下所示的spring活动配置文件来运行spring boot应用程序:
I am running the spring boot app by passing the spring active profile like below:
spring-boot:run -Dspring.profiles.active=dev
但是在使用maven创建软件包时如何传递spring.profiles.active.以下是maven命令:
But how do I pass the spring.profiles.active when creating the package using maven. Following is the maven command:
mvn clean install
Maven是一个构建时工具,使其修改已构建工件的最终运行时行为的唯一方法是使用其( build-时间)配置文件.请勿将此与Spring的 runtime 配置文件混淆,这些配置文件是指示Spring容器以特定方式引导应用程序的参数.
Maven is a build-time tool, the only way to make it modify the eventual runtime behaviour of the built artifact is to use its (build-time) profiles. This must not be confused with Spring's runtime profiles which are parameters instructing the Spring container to bootstrap application in a specific way.
换句话说,spring.profiles.active
参数不会被maven烘焙"到战争文件中,您仍然需要在启动应用程序时通过命令行参数或配置文件将其传递给它.或Servlet容器提供的任何机制.
In other words, the spring.profiles.active
parameter doesn't get "baked into" the war file by maven, you'll still need to pass it when starting the application up, be it via command-line parameters or configuration file or whatever mechanism your servlet container offers.