我正在尝试将我的项目打包到.war一个tomcat服务器部署中.我需要用我的能力application.properties OR application-dev.properties 或 appliation-qa.properties OR application-prod.properties.使用嵌入的servlet运行项目我可以通过命令行指定我想要使用的项目,但是,application.properties当我将它打包为一个项目时,项目总是使用.war.
我使用以下命令在本地运行我的项目:
mvn spring-boot:runmvn spring-boot:run -Drun.arguments="--spring.profiles.active=dev"这个命令将我的项目打包成竹子进行部署:
mvn package -Dspring.profiles.active=qaApplication.java
package com.pandera.wilson;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.env.AbstractEnvironment;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import org.apache.log4j.Logger;
/**
* @author Gaurav Kataria
* @author Austin Nicholas
* @category Application
*/
@SpringBootApplication
@ComponentScan(basePackages = { "com.pandera.wilson" })
@EnableAsync
public class Application extends SpringBootServletInitializer {
static final Logger logger …Run Code Online (Sandbox Code Playgroud)