Is it possible to add a datasource or jdbc-driver by executing the wildfly:add-resource goal. I only get a warning when executing the goal which says "No resources were provided".
I used the "Adding Datasource" example from the projects documentation. (https://docs.jboss.org/wildfly/plugins/maven/latest/examples/add-resource-example.html)
Executing the package
lifecycle adds the datasource to the standalone.xml but executing mvn wildfly:add-resource
exits with the No resource were provided
message.
Thanks for helping!
I only use the maven-wildfly-plugin for local development. So i want to execute a single goal to configure my local application server.
Here a brief summary of my 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>