【发布时间】:2015-05-20 12:32:20
【问题描述】:
我有一个创建 war 文件的 maven 项目,应该通过 wildfly:run 将其部署到捆绑的 Wildfly 服务器。
到目前为止,这有效,但我需要在部署之前创建一个数据源。
我尝试将 add-resource 目标绑定到部署、安装或打包等不同阶段。他们都没有工作。
怎么了?
一个想法是使用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>
【问题讨论】: