我想我誤解了Spring啓動配置文件功能。 我在春天啓動的應用程序有兩個獨立的啓動類(ApplicationLocal和ApplicationProduction), 這些類註釋這樣如何根據活動彈簧配置文件切換彈簧啓動啓動類
@SpringBootApplication
@EnableSwagger2
@Import(value={Config.class})
@ComponentScan(basePackages={"com.abc.*"})
@Profile("local")
public class ApplicationLocal extends SpringBootServletInitializer {
//
@SpringBootApplication
@EnableSwagger2
@Import(value={Config.class})
@ComponentScan(basePackages={"com.abc.*"})
@Profile("production")
public class ApplicationProduction extends SpringBootServletInitializer {
//
,我想在這取決於運行時得到回升相應的啓動類增長春天啓動-Dspring.profiles.active jvm爭論的價值。 但它不是爲我工作,除非我提到的啓動類部分的pom.xml 這樣的..
<properties>
<start-class>com.abc.web.service.ApplicationLocal</start-class>
</properties>
如果我不提在pom.xml中的啓動類,然後我得到以下錯誤: (我運行應用程序如下
mvn spring-boot:run -Drun.jvmArguments=" -Dspring.profiles.active=local"
而且我得到以下錯誤
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.3.3.RELEASE:run (default-cli) on project payee-list-ws: Execution default-cli of goal org.springframework.boot:spring-boot-maven-plugin:1.3.3.RELEASE:run failed: Unable to find a single main class from the following candidates [com.abc.web.service.ApplicationProduction, com.abc.web.service.ApplicationLocal] -> [Help 1]
真的需要有不同的課程嗎?每個配置文件有多少不同的業務邏輯?還是隻有一些配置不同,如不同的數據庫連接或如此? – Patrick