2015-05-20 27 views
0

我有一個創建war文件的maven項目,這應該通過wildfly:run部署到捆綁的wild server服務器。
目前爲止,但我需要在部署之前創建一個數據源。創建數據源並部署應用程序

我試圖將添加資源目標綁定到不同的階段,如部署,安裝或打包。他們都沒有工作。

出了什麼問題?

一個想法是使用wildfly:start附加一個執行來添加數據源並部署應用程序,但我不知道如何。

<groupId>org.wildfly.plugins</groupId> 
<artifactId>wildfly-maven-plugin</artifactId> 
<executions> 
    <execution> 
     <id>add-datasource</id> 
     <phase>deploy</phase> 
     <goals> 
      <goal>add-resource</goal> 
     </goals> 
     <configuration> 
      <address>subsystem=datasources,data-source=java:jboss/testDB</address> 
      <resources> 
       <resource> 
        <properties> 
         <jndi-name>java:jboss/testDB</jndi-name> 
         <enabled>true</enabled> 
         <connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1</connection-url> 
         <driver-class>org.h2.Driver</driver-class> 
         <driver-name>h2</driver-name> 
         <user-name>sa</user-name> 
         <password>sa</password> 
        </properties> 
       </resource> 
      </resources> 
     </configuration> 
    </execution> 
</executions> 

回答

2

我的解決方法是使用運行目標和beforeDeployment目標:

<plugin> 
    <groupId>org.wildfly.plugins</groupId> 
    <artifactId>wildfly-maven-plugin</artifactId> 
    <configuration> 
     <beforeDeployment> 
      <commands> 
       <command>data-source add --jndi-name=java:jboss/datasources/OracleDS --name=testDB --connection-url=jdbc:h2:mem:test;DB_CLOSE_DELAY=-1 --driver-name=h2 --user-name=sa --password=sa</command> 
      </commands> 
     </beforeDeployment> 
    </configuration> 
</plugin> 
相關問題