2011-01-21 89 views
0

我嘗試以嵌入式形式啓動碼頭,但我遇到問題嵌入式jetty maven profile.xml

我需要在嵌入式jetty啓動之前讀取profile.xml中的屬性值。

有什麼建議嗎?

這裏是profile.xml配置的內容

..... 
    <profile> 
      <id>local-dev</id> 
      <activation> 
       <activeByDefault>false</activeByDefault> 
      </activation> 
      <properties> 
       <!-- Common Security Framework Properties --> 
       <security.context.file>applicationContext-security-csf.xml</security.context.file> 
       <csf.jndi.name>jdbc/securityDS</csf.jndi.name> 
       <csf.security.system.admin.roleId>884</csf.security.system.admin.roleId>    
       <csf.cas.url>tkvwasa01.secure.kodcu.com</csf.cas.url> 
       <application.service.url>localhost:8080/pqis-admin</application.service.url> 
      </properties> 
     </profile> 

在Maven的身邊,我可以激活上述個人資料(本地開發),如

命令mvn碼頭:運行本地開發

,但我怎麼能當我使用Embedded Jetty時,激活上面的配置文件(local-dev)?

嵌入式碼頭的代碼:

 

public class Start { 

    public static void main(String[] args) throws Exception { 
     Server server = new Server(); 
     SocketConnector connector = new SocketConnector(); 

     // Set some timeout options to make debugging easier. 
     connector.setMaxIdleTime(1000 * 60 * 60); 
     connector.setSoLingerTime(-1); 
     connector.setPort(8080); 
     server.setConnectors(new Connector[] { connector }); 

     WebAppContext bb = new WebAppContext(); 
     bb.setServer(server); 
     bb.setContextPath("/"); 
     bb.setWar("src/main/webapp"); 
       ..... 
    } 
} 
 

感謝。

+0

你有什麼問題?也許你應該發佈你的相關pom片段,假設你正在嘗試通過maven開始它 – Raghuram 2011-01-21 10:18:54

+1

當你運行你的嵌入式碼頭(Start類)時,maven會如何進入圖片? – Raghuram 2011-01-21 11:13:53

回答

0

此配置文件默認處於活動狀態嗎?另一個配置文件是否活如果另一個配置文件處於活動狀態,則默認激活的配置文件將被禁用。

[編輯]

那麼,the documentation狀態,可以在命令行使用-P選項激活配置文件:

mvn groupId:artifactId:goal -P profile-1,profile-2 

但是,POM性質並不意在被使用運行時間,但在構建時間。例如,您可以將這些屬性用於filter資源(XML/.properties配置文件),用屬性值替換佔位符標記。然後,運行構建的應用程序。