Wildfly 10 Java EE EAR项目中缺少工件错误

时间:2017-02-02 04:13:21

标签: maven java-ee jboss wildfly wildfly-10

我使用向导创建了一个Java EE EAR项目。我在耳朵和web子项目的pom文件中都有错误。没有与ejb pom文件的错误。

这是我得到的错误......

缺少工件org.jboss.ejb3:jboss-ejb3-web:war:1.0.0

这是ear子项目的pom文件

<?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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <artifactId>jboss-ejb3</artifactId>
        <groupId>org.jboss.ejb3</groupId>
        <version>1.0.0</version>
    </parent>

    <artifactId>jboss-ejb3-ear</artifactId>
    <packaging>ear</packaging>

    <name>jboss-ejb3: EAR Module</name>

    <url>http://wildfly.org</url>
    <licenses>
        <license>
            <name>Apache License, Version 2.0</name>
            <distribution>repo</distribution>
            <url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
        </license>
    </licenses>

    <dependencies>

        <!-- Depend on the ejb module and war so that we can package them -->
        <dependency>
            <groupId>org.jboss.ejb3</groupId>
            <artifactId>jboss-ejb3-web</artifactId>
            <type>war</type>
        </dependency>
        <dependency>
            <groupId>org.jboss.ejb3</groupId>
            <artifactId>jboss-ejb3-ejb</artifactId>
            <type>ejb</type>
        </dependency>
    </dependencies>

    <build>
        <finalName>${project.artifactId}</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-ear-plugin</artifactId>
                <version>${version.ear.plugin}</version>
                <configuration>
                    <!-- Tell Maven we are using Java EE 7 -->
                    <version>7</version>
                    <!-- Use Java EE ear libraries as needed. Java EE ear libraries 
                        are in easy way to package any libraries needed in the ear, and automatically 
                        have any modules (EJB-JARs and WARs) use them -->
                    <defaultLibBundleDir>lib</defaultLibBundleDir>
                    <fileNameMapping>no-version</fileNameMapping>
                </configuration>
            </plugin>
            <!-- The WildFly plugin deploys your ear to a local WildFly container -->
            <!-- Due to Maven's lack of intelligence with EARs we need to configure 
                the wildfly maven plugin to skip deployment for all modules. We then enable
                it specifically in the ear module. -->
            <plugin>
                <groupId>org.wildfly.plugins</groupId>
                <artifactId>wildfly-maven-plugin</artifactId>
                <configuration>
                    <filename>${project.artifactId}.ear</filename>
                    <skip>false</skip>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <!-- When built in OpenShift the 'openshift' profile will be used when invoking mvn. -->
            <!-- Use this profile for any OpenShift specific customization your app will need. -->
            <!-- By default that is to put the resulting archive into the 'deployments' folder. -->
            <!-- http://maven.apache.org/guides/mini/guide-building-for-different-environments.html -->
            <id>openshift</id>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-ear-plugin</artifactId>
                        <version>${version.ear.plugin}</version>
                        <configuration>
                            <outputDirectory>deployments</outputDirectory>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>

这是web子项目的pom文件

<?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/maven-v4_0_0.xsd">
   <modelVersion>4.0.0</modelVersion>

   <parent>
      <artifactId>jboss-ejb3</artifactId>
      <groupId>org.jboss.ejb3</groupId>
      <version>1.0.0</version>
   </parent>

   <artifactId>jboss-ejb3-web</artifactId>
   <packaging>war</packaging>

   <name>jboss-ejb3: WAR Module</name>

   <url>http://wildfly.org</url>
   <licenses>
      <license>
         <name>Apache License, Version 2.0</name>
         <distribution>repo</distribution>
         <url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
      </license>
   </licenses>

   <dependencies>

      <!-- Dependency on the EJB module so we can use it's services if needed -->
      <dependency>
         <groupId>org.jboss.ejb3</groupId>
         <artifactId>jboss-ejb3-ejb</artifactId>
         <type>ejb</type>
         <scope>provided</scope>
      </dependency>

      <!-- Import the JAX-RS API, we use provided scope as the API is included in JBoss WildFly -->
      <dependency>
         <groupId>org.jboss.resteasy</groupId>
         <artifactId>jaxrs-api</artifactId>
         <scope>provided</scope>
      </dependency>

      <!-- Import the CDI API, we use provided scope as the API is included in JBoss WildFly -->
      <dependency>
         <groupId>javax.enterprise</groupId>
         <artifactId>cdi-api</artifactId>
         <scope>provided</scope>
      </dependency>

      <!-- Import the JSF API, we use provided scope as the API is included in JBoss WildFly -->
      <dependency>
         <groupId>org.jboss.spec.javax.faces</groupId>
         <artifactId>jboss-jsf-api_2.2_spec</artifactId>
         <scope>provided</scope>
      </dependency>

      <!-- Import the JPA API, we use provided scope as the API is included in JBoss WildFly -->
      <dependency>
         <groupId>org.hibernate.javax.persistence</groupId>
         <artifactId>hibernate-jpa-2.1-api</artifactId>
         <scope>provided</scope>
      </dependency>

       <!-- JSR-303 (Bean Validation) Implementation -->
       <!-- Provides portable constraints such as @Email -->
       <!-- Hibernate Validator is shipped in JBoss WildFly -->
       <dependency>
           <groupId>org.hibernate</groupId>
           <artifactId>hibernate-validator</artifactId>
           <scope>provided</scope>
           <exclusions>
               <exclusion>
                   <groupId>org.slf4j</groupId>
                   <artifactId>slf4j-api</artifactId>
               </exclusion>
           </exclusions>
       </dependency>

   </dependencies>

   <build>
      <finalName>${project.artifactId}</finalName>
      <plugins>
         <plugin>
            <artifactId>maven-war-plugin</artifactId>
            <version>${version.war.plugin}</version>
            <configuration>
               <!-- Java EE 7 doesn't require web.xml, Maven needs to catch up! -->
               <failOnMissingWebXml>false</failOnMissingWebXml>
            </configuration>
         </plugin>
      </plugins>
   </build>

</project>

错误发生在pom文件的这个区域

  <dependency>
     <groupId>org.jboss.ejb3</groupId>
     <artifactId>jboss-ejb3-ejb</artifactId>
     <type>ejb</type>
     <scope>provided</scope>
  </dependency>

如何解决此错误?

1 个答案:

答案 0 :(得分:0)

父pom文件中必须有一个模块部分,并确保依赖项依赖于依赖项。

    <modules>
        <module>core-module</module>
        <module>depends-on-core</module>
        <module>depends-on-core2</module>
        <module>depends-on-depends-on-core</module>
    </modules>

安排后更新maven。