[英]add-resource Data Source with wildfly-maven-plugin
在maven全新安裝的第一次運行中,驅動程序和數據源以及應用程序已成功部署。 但是,當執行另一個Maven全新安裝時,日志會通知該數據源已被注冊。
如何解決此問題,我已經在文檔中查看了,我沒有想到如何防止重新植入數據源
的pom.xml
<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>
<groupId>com.sistema</groupId>
<artifactId>sgr</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<maven-compiler.version>3.3</maven-compiler.version>
<maven-war-plugin.version>2.6</maven-war-plugin.version>
<properties-maven-plugin.version>1.0.0</properties-maven-plugin.version>
<wildfly-maven-plugin.version>1.1.0.Beta1</wildfly-maven-plugin.version>
<mysql-connector-java.version>5.1.39</mysql-connector-java.version>
<flyway-maven-plugin.version>4.0.2</flyway-maven-plugin.version>
<primefaces-version>6.0</primefaces-version>
</properties>
<dependencies>
<!-- MySql Conector -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql-connector-java.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>../src/main/java</sourceDirectory>
<finalName>sgr-${project.version}</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler.version}</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>${maven-war-plugin.version}</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>${wildfly-maven-plugin.version}</version>
<executions>
<!-- Add Driver JDBC MySql no servidor -->
<execution>
<id>deploy-driver</id>
<phase>install</phase>
<configuration>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql-connector-java.version}</version>
<name>mysql-connector-java-${mysql-connector-java.version}</name>
<driver-name>mysql-connector-java-${mysql-connector-java.version}</driver-name>
</configuration>
<goals>
<goal>deploy-artifact</goal>
</goals>
</execution>
<!-- Add data source da aplicação no servidor -->
<execution>
<id>add-datasource</id>
<phase>install</phase>
<configuration>
<force>false</force>
<address>subsystem=datasources,data-source=SGRDS</address>
<resources>
<resource>
<properties>
<jndi-name>java:jboss/datasources/SGRDS</jndi-name>
<enable>true</enable>
<connection-url>jdbc:mysql://localhost/sgrdb?useSSL=false</connection-url>
<driver-name>mysql-connector-java-5.1.39_com.mysql.jdbc.Driver_5_1</driver-name>
<user-name>root</user-name>
<password>2cs2dlmf</password>
</properties>
</resource>
</resources>
<retryFailedDeploymentCount>1</retryFailedDeploymentCount>
</configuration>
<goals>
<goal>add-resource</goal>
</goals>
</execution>
<!-- Realiza deploy no servidor e install da aplicação no repositório -->
<execution>
<id>deploy</id>
<phase>install</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
force = true ERRO數據源已注冊。
假=假
ERRO
ERROR [org.jboss.msc.service.fail] (MSC service thread 1-3) MSC000001: Failed to start service jboss.deployment.unit."sgr-0.0.1-SNAPSHOT.war".component."com.sun.faces.config.ConfigureListener".WeldInstantiator: org.jboss.msc.service.StartException in service jboss.deployment.unit."sgr-0.0.1-SNAPSHOT.war".component."com.sun.faces.config.ConfigureListener".WeldInstantiator: Failed to start service
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1904)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalStateException: WFLYWELD0041: WeldContainer is not started
at org.jboss.as.weld.WeldBootstrapService.getBeanManager(WeldBootstrapService.java:183)
at org.jboss.as.weld.injection.WeldComponentService.start(WeldComponentService.java:97)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)
... 3 more
16:23:23,658 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-3) MSC000001: Failed to start service jboss.deployment.unit."sgr-0.0.1-SNAPSHOT.war".component."javax.servlet.jsp.jstl.tlv.ScriptFreeTLV".WeldInstantiator: org.jboss.msc.service.StartException in service jboss.deployment.unit."sgr-0.0.1-SNAPSHOT.war".component."javax.servlet.jsp.jstl.tlv.ScriptFreeTLV".WeldInstantiator: Failed to start service
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1904)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalStateException: WFLYWELD0041: WeldContainer is not started
at org.jboss.as.weld.WeldBootstrapService.getBeanManager(WeldBootstrapService.java:183)
at org.jboss.as.weld.injection.WeldComponentService.start(WeldComponentService.java:97)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)
... 3 more
16:23:23,658 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-3) MSC000001: Failed to start service jboss.deployment.unit."sgr-0.0.1-SNAPSHOT.war".component."javax.servlet.jsp.jstl.tlv.PermittedTaglibsTLV".WeldInstantiator: org.jboss.msc.service.StartException in service jboss.deployment.unit."sgr-0.0.1-SNAPSHOT.war".component."javax.servlet.jsp.jstl.tlv.PermittedTaglibsTLV".WeldInstantiator: Failed to start service
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1904)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalStateException: WFLYWELD0041: WeldContainer is not started
at org.jboss.as.weld.WeldBootstrapService.getBeanManager(WeldBootstrapService.java:183)
at org.jboss.as.weld.injection.WeldComponentService.start(WeldComponentService.java:97)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)
... 3 more
16:23:23,658 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-3) MSC000001: Failed to start service jboss.deployment.unit."sgr-0.0.1-SNAPSHOT.war".CdiValidatorFactoryService: org.jboss.msc.service.StartException in service jboss.deployment.unit."sgr-0.0.1-SNAPSHOT.war".CdiValidatorFactoryService: Failed to start service
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1904)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalStateException: WFLYWELD0041: WeldContainer is not started
at org.jboss.as.weld.WeldBootstrapService.getBeanManager(WeldBootstrapService.java:207)
at org.jboss.as.weld.CdiValidatorFactoryService.start(CdiValidatorFactoryService.java:77)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)
... 3 more
16:23:23,659 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-3) MSC000001: Failed to start service jboss.deployment.unit."sgr-0.0.1-SNAPSHOT.war".component."org.jboss.weld.servlet.WeldTerminalListener".WeldInstantiator: org.jboss.msc.service.StartException in service jboss.deployment.unit."sgr-0.0.1-SNAPSHOT.war".component."org.jboss.weld.servlet.WeldTerminalListener".WeldInstantiator: Failed to start service
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1904)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalStateException: WFLYWELD0041: WeldContainer is not started
at org.jboss.as.weld.WeldBootstrapService.getBeanManager(WeldBootstrapService.java:183)
at org.jboss.as.weld.injection.WeldComponentService.start(WeldComponentService.java:97)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)
... 3 more
16:23:23,659 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-3) MSC000001: Failed to start service jboss.deployment.unit."sgr-0.0.1-SNAPSHOT.war".component."org.jboss.weld.servlet.WeldInitialListener".WeldInstantiator: org.jboss.msc.service.StartException in service jboss.deployment.unit."sgr-0.0.1-SNAPSHOT.war".component."org.jboss.weld.servlet.WeldInitialListener".WeldInstantiator: Failed to start service
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1904)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalStateException: WFLYWELD0041: WeldContainer is not started
at org.jboss.as.weld.WeldBootstrapService.getBeanManager(WeldBootstrapService.java:183)
at org.jboss.as.weld.injection.WeldComponentService.start(WeldComponentService.java:97)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)
... 3 more
16:23:23,659 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-3) MSC000001: Failed to start service jboss.deployment.unit."sgr-0.0.1-SNAPSHOT.war".component."javax.faces.webapp.FacetTag".WeldInstantiator: org.jboss.msc.service.StartException in service jboss.deployment.unit."sgr-0.0.1-SNAPSHOT.war".component."javax.faces.webapp.FacetTag".WeldInstantiator: Failed to start service
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1904)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalStateException: WFLYWELD0041: WeldContainer is not started
at org.jboss.as.weld.WeldBootstrapService.getBeanManager(WeldBootstrapService.java:183)
at org.jboss.as.weld.injection.WeldComponentService.start(WeldComponentService.java:97)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)
... 3 more
16:23:23,661 WARN [org.jboss.msc.service.fail] (MSC service thread 1-3) MSC000004: Failure during stop of service jboss.deployment.unit."sgr-0.0.1-SNAPSHOT.war".WeldStartService: java.lang.IllegalStateException: WFLYWELD0041: WeldContainer is not started
at org.jboss.as.weld.WeldStartService.stop(WeldStartService.java:121)
at org.jboss.msc.service.ServiceControllerImpl$StopTask.stopService(ServiceControllerImpl.java:2056)
at org.jboss.msc.service.ServiceControllerImpl$StopTask.run(ServiceControllerImpl.java:2017)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
新的Pom.xml和相同的錯誤WFLYWELD0041:WeldContainer未啟動
<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>
<groupId>com.sistema</groupId>
<artifactId>sgr</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<wildfly.version>10.1.0.Final</wildfly.version>
<maven-compiler.version>3.3</maven-compiler.version>
<maven-war-plugin.version>2.6</maven-war-plugin.version>
<properties-maven-plugin.version>1.0.0</properties-maven-plugin.version>
<wildfly-maven-plugin.version>1.1.0.Beta1</wildfly-maven-plugin.version>
<mysql-connector-java.version>5.1.39</mysql-connector-java.version>
<flyway-maven-plugin.version>4.0.2</flyway-maven-plugin.version>
<primefaces-version>6.0</primefaces-version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.wildfly.bom</groupId>
<artifactId>wildfly-javaee7-with-tools</artifactId>
<version>${wildfly.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-spec-api</artifactId>
<version>${wildfly.version}</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql-connector-java.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>${primefaces-version}</version>
</dependency>
</dependencies>
<build>
<finalName>sgr-${project.version}</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler.version}</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>${maven-war-plugin.version}</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>${wildfly-maven-plugin.version}</version>
<executions>
<!-- Add Driver JDBC MySql no servidor -->
<execution>
<id>deploy-driver</id>
<phase>install</phase>
<configuration>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql-connector-java.version}</version>
<name>mysql-connector-java-${mysql-connector-java.version}</name>
<driver-name>mysql-connector-java-${mysql-connector-java.version}</driver-name>
</configuration>
<goals>
<goal>deploy-artifact</goal>
</goals>
</execution>
<!-- Add data source da aplicação no servidor -->
<execution>
<id>add-datasource</id>
<phase>install</phase>
<configuration>
<force>false</force>
<address>subsystem=datasources,data-source=SGRDS</address>
<resources>
<resource>
<properties>
<jndi-name>java:jboss/datasources/SGRDS</jndi-name>
<enable>true</enable>
<connection-url>jdbc:mysql://localhost/sgrdb?useSSL=false</connection-url>
<driver-name>mysql-connector-java-5.1.39_com.mysql.jdbc.Driver_5_1</driver-name>
<user-name>root</user-name>
<password>2cs2dlmf</password>
</properties>
</resource>
</resources>
<retryFailedDeploymentCount>1</retryFailedDeploymentCount>
</configuration>
<goals>
<goal>add-resource</goal>
</goals>
</execution>
<!-- Realiza deploy no servidor e install da aplicação no repositório -->
<execution>
<id>deploy</id>
<phase>install</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-maven-plugin</artifactId>
<version>${flyway-maven-plugin.version}</version>
<configuration>
<configFile>${project.build.directory}/classes/flyway.properties</configFile>
<url>${flyway.url}</url>
<user>${flyway.user}</user>
<password>${flyway.password}</password>
<schemas>
<schema>${flyway.schemas}</schema>
</schemas>
</configuration>
</plugin>
</plugins>
</build>
</project>
LOG ERRO MAVEN
第二次成功執行maven安裝后,會發生該錯誤。
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 17.461 s
[INFO] Finished at: 2016-12-12T20:45:05-02:00
[INFO] Final Memory: 19M/48M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.wildfly.plugins:wildfly-maven-plugin:1.1.0.Beta1:add-resource (add-datasource) on project sgr: Could not execute goal add-resource. Reason: Resource [
[ERROR] ("subsystem" => "datasources"),
[ERROR] ("data-source" => "SGRDS")
[ERROR] ] already exists.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
我認為你應該使用武力 :)
您的配置應如下所示:
<!-- Add data source da aplicação no servidor -->
<execution>
<id>add-datasource</id>
<phase>install</phase>
<configuration>
<force>true</force> <!-- or false, not sure -->
...
</execution>
我不確定是否必須將其設置為true或false。 該文檔說您應該將其設置為true,但是它是默認值,也許您可以嘗試使用false。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.