2014-06-11 32 views
3

我正在尋找一種方法來設置碼頭春天輪廓編程,使應用程序所使用指定的配置文件服務器上的war文件,這是我的代碼:碼頭春天輪廓編程

final WebAppContext context = new WebAppContext(); 
context.setLogUrlOnStart(true); 
context.setWar("target/deployables/myapp-rest/myapp-rest.war"); 
context.setContextPath("/" + TEST_APP_CONTEXT); 
context.setParentLoaderPriority(true); 
server.setHandler(context); 
server.start(); 

我嘗試了幾件事,但沒有一個似乎工作...我需要通過-Dspring.profiles.active = myProfile

回答

0

這是測試與Jetty 9.3但webdefault.xml似乎也可用於較低版本(它的位置可能會有所不同)。

轉到$JETTY_HOME/etc並打開webdefault.xml。在文件中搜索context-param。下面的地方添加以下代碼:

<context-param> 
    <param-name>spring.profiles.default</param-name> 
    <param-value>prod</param-value> 
</context-param> 

如果您web.xml(在your-app.war文件)不包含此context-param這將工作。

否則,你也可以使用override-web.xmldocs),但你需要配置它在jetty-web.xmljetty-web.xml必須捆綁戰爭裏面...所以因人而異,但我不想改變我的戰爭和webdefault.xml是更容易爲我解決。