2012-02-14 64 views
3

我有以下用例: 我有一個使用Spring WS實現的Web服務通過Spring MVC實現的Web應用程序。maven-embedded-glassfish-plugin部署2個應用程序

這些項目使用maven作爲構建工具。 現在我想實現Web應用程序的集成測試。 爲此,我想使用maven-embedded-glassfish-plugin。 我在pom.xml中有以下maven配置:

<plugin> 
    <groupId>org.glassfish</groupId> 
    <artifactId>maven-embedded-glassfish-plugin</artifactId> 
     <version>3.1.1</version> 
     <configuration> 
      <goalPrefix>embedded-glassfish</goalPrefix> 
      <app>${basedir}/target/web-app.war</app> 

      <autoDelete>true</autoDelete> 
      <port>8080</port> 
      <name>web-app</name> 

      <configFile>src/test/resources/glassfish/domain.xml</configFile> 
     </configuration> 

     <executions> 
      <execution> 
       <id>start-glassfish</id> 
       <phase>pre-integration-test</phase> 
       <goals> 
       <goal>start</goal> 
       </goals> 
      </execution> 
      <execution> 
       <id>glassfish-deploy</id> 
       <phase>pre-integration-test</phase> 
       <goals> 
       <goal>deploy</goal> 
       </goals> 
      </execution> 
      <execution> 
       <id>glassfish-undeploy</id> 
       <phase>post-integration-test</phase> 
       <goals> 
       <goal>undeploy</goal> 
       </goals> 
      </execution> 
      <execution> 
       <id>stop-glassfish</id> 
       <phase>post-integration-test</phase> 
       <goals> 
       <goal>stop</goal> 
       </goals> 
      </execution> 
     </executions> 
     </plugin> 

一切工作正常。 但現在我需要添加webservice.war文件的部署。 這不是我在這一刻的依賴。 我只有一個存根類,用於調用web-app.war應用程序中定義的Web服務。

那麼,如何部署這第二個應用程序的任何良好的解決方案?

我想成爲自動的東西,也許使用它的Maven倉庫,如果我做了修改,我想自動使用新版本的Web服務。

回答

3

我發現有[email protected]和先生伯瓦尼桑卡以下解決方案的幫助:

<execution> 
     <id>glassfish-additional_deployments</id> 
     <phase>pre-integration-test</phase> 
     <goals> 
     <goal>admin</goal> 
     </goals> 
     <configuration> 
     <commands> 
      <param>deploy ${basedir}/src/test/resources/integrationtest/app-ws.war</param> 
     </commands> 
     </configuration> 
    </execution> 

Teoretically可以設置依賴於戰爭的行家,然後部署war目錄中的war文件也是如此。

一些有趣的關於這個插件,如果有人想使用的選項:

<instanceRoot>${project.build.directory}/glassfish</instanceRoot> 

沒有在版本3.1.1工作只能用現有的GlassFish安裝。 如果你想設置該屬性然後使用(而不必一次GlassFish的安裝):

 <systemProperties> 
     <property>glassfish.embedded.tmpdir=target/glassfish</property> 
     </systemProperties> 
0

對於3.1.1版本的Maven的嵌入與GlassFish插件,你只需要設置「GlassFish的。 embedded.tmpdir「屬性到一個靜態值(對於Windows操作系統,但我不確定對於Linux)。因爲maven不能轉換路徑。

我正在爲玻璃魚部署一個耳朵,它完全爲我工作。

我的配置是:

<plugin> 
      <groupId>org.glassfish</groupId> 
      <artifactId>maven-embedded-glassfish-plugin</artifactId> 
      <version>3.1.1</version> 
      <configuration> 
       <systemProperties> 
        <property>glassfish.embedded.tmpdir=target/glassfish</property> 
       </systemProperties> 
       <app>${project.build.directory}/${build.finalName}.ear</app> 
       <autoDelete>true</autoDelete> 
       <port>8080</port> 
       <contextRoot>test</contextRoot> 
      </configuration> 
      <executions> 
       <execution> 
        <id>start-glassfish</id> 
        <phase>install</phase> 
        <goals> 
         <goal>run</goal> 
        </goals> 
       </execution> 
      </executions> 
     </plugin> 

但如果我刪除<property>glassfish.embedded.tmpdir=target/glassfish</property>

部分,然後啓動服務器,它加載的項目慢慢真的很有趣,它不是穩定的。