是否可以通过执行 wildfly:add-resource 目标来添加数据源或 jdbc 驱动程序。我只在执行“未提供资源”的目标时收到警告。
我使用了项目文档中的“添加数据源”示例。 (https://docs.jboss.org/wildfly/plugins/maven/latest/examples/add-resource-example.html)
执行
package
生命周期将数据源添加到 standalone.xml 但执行 mvn wildfly:add-resource
退出并显示 No resource were provided
消息。
感谢您的帮助!
本地开发我只使用maven-wildfly-plugin。所以我想执行一个单一的目标来配置我的本地应用程序服务器。
这里是我的 pom.xml 的简要总结。
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
...
<packaging>war</packaging>
<name>${project.artifactId}</name>
<properties>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>4.1.0.Beta1</version>
<configuration>
<id>standalone</id>
<hostname>localhost</hostname>
<port>9990</port>
<username>admin</username>
<password>admin</password>
<startupTimeout>120</startupTimeout>
</configuration>
<executions>
<execution>
<id>add-datasource</id>
<phase>package</phase>
<goals>
<goal>add-resource</goal>
</goals>
<configuration>
<address>subsystem=datasources,data-source=java:jboss/myDs</address>
<resources>
<resource>
<properties>
<jndi-name>java:jboss/myDs</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>
</plugin>
</plugins>
</build>
</project>