在Maven Clean Install的第一次运行中,驱动程序和数据源以及应用程序已成功部署。但是,在执行另一个Maven Clean安装时,日志告知数据源已注册。
如何解决这个问题,我已经在文档中查看过,我认为如何防止这种数据植入dataSource
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数据源已经注册。
false = false
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)
new 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,我不确定是否很难。DocumentAiton说您应该将其设置为true,但这是默认值,也许您可以尝试使用false。