简体   繁体   English

无法执行目标org.apache.maven.plugins:maven-jar-plugin:2.4:jar

[英]Failed to execute goal org.apache.maven.plugins:maven-jar-plugin:2.4:jar

So I was trying to go ahead and create a .ear file for an existing maven project and further deploy it on WebLogic server . 因此,我试图继续为现有的maven项目创建.ear文件,然后将其进一步部署在WebLogic server For the same, I went ahead to create the WAR , JAR and the EAR module and followed these steps for it - 同样,我继续创建WARJAREAR模块,并按照以下步骤进行操作-

Right click on parent project , select new , select maven module , Named it as projectnameJARModule and then finished the wizard . Right click parent project ,选择new ,选择maven module ,将其命名为projectnameJARModule ,然后完成wizard

Did the same process for creating a projectnameWARModule and a projectnameEARModule module. 创建项目名称projectnameWARModule和项目名称projectnameEARModule模块的过程相同。 Once they were made, I added the WAR and the JAR modules as dependencies to the EAR module .Further, I went ahead to install the maven modules by Right Clicking on the projectnameWARModule folder and chose Run As - Maven Install . 制作完成后,我将WARJAR模块作为dependenciesEAR module 。此外,我继续通过Right Clicking projectnameWARModule文件夹来安装maven modules ,然后选择Run As - Maven Install Upon this, I get the following error in the console (Full console log below) - 基于此,我在控制台中收到以下错误(下面是完整的控制台日志)-


T E S T S
-------------------------------------------------------
Running org.CADJARModule.AppTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec

Results :

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

[INFO] 
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ CADJARModule ---
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] projectname ............................................... SUCCESS [  0.957 s]
[INFO] projectnameJARModule ...................................... FAILURE [ 33.425 s]
[INFO] projectnameWARModule Maven Webapp ......................... SKIPPED
[INFO] projectnameEARModule ...................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 34.806 s
[INFO] Finished at: 2015-12-01T18:16:20+05:30
[INFO] Final Memory: 9M/126M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-jar-plugin:2.4:jar (default-jar) on project projectnameJARModule: Error assembling JAR: For artifact {org.glassfish.jersey.containers:jersey-container-servlet-core:null:jar}: The version cannot be empty. -> [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
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :projectnameJARModule

Any idea how do I get rid of this? 知道我该如何摆脱吗? Many Thanks 非常感谢

Following is the pom.xml for the Parent Module - 以下是Parent Modulepom.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>Project_name</groupId>
<artifactId>Project_name</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Project_name</name>
<build>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
                <version>2.5.1</version>
                <inherited>true</inherited>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
    <plugin>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.4</version>
        <configuration>
        <warSourceDirectory>WebContent</warSourceDirectory>
        <failOnMissingWebXml>false</failOnMissingWebXml>
        </configuration>
    </plugin>
    </plugins>
</build>
<dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.glassfish.jersey</groupId>
                <artifactId>jersey-bom</artifactId>
                <version>${jersey.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>com.fasterxml.jackson.jaxrs</groupId>
                <artifactId>jackson-jaxrs-json-provider</artifactId>
                <version>2.6.0</version>
        </dependency>
        <dependency>
                    <groupId>javax</groupId>
                    <artifactId>javaee-web-api</artifactId>
                    <version>7.0</version> <!-- Put here the version of your Java EE app, in my case 7.0 -->
                    <scope>provided</scope>
            </dependency>

          <dependency>
                    <groupId>javax.servlet</groupId>
                    <artifactId>javax.servlet-api</artifactId>
                    <version>3.1.0</version>
                    <scope>provided</scope>
            </dependency>

            <dependency>
                    <groupId>javax.servlet</groupId>
                    <artifactId>jstl</artifactId>
                    <version>1.2</version>
            </dependency>

        <dependency>
            <groupId>org.glassfish.jersey.containers</groupId>
            <artifactId>jersey-container-servlet-core</artifactId>
            <!-- use the following artifactId if you don't need servlet 2.x compatibility -->
            <!-- artifactId>jersey-container-servlet</artifactId -->
        </dependency>

        <dependency>
            <groupId>org.glassfish.jersey.media</groupId>
            <artifactId>jersey-media-moxy</artifactId>
        </dependency>
        </dependencies>
    </dependencyManagement>


    <properties>
        <jersey.version>2.16</jersey.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <modules>
        <module>Project_nameJARModule</module>
        <module>Project_nameWARModule</module>
        <module>Project_nameEARModule</module>
    </modules>
</project>

Following is the pom.xml for the WAR Module - 以下是WAR Modulepom.xml

    <?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
    <groupId>Projectname</groupId>
    <artifactId>Projectname</artifactId>
    <version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>ProjectnameWARModule</groupId>
<artifactId>ProjectnameWARModule</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>ProjectnameWARModule Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
    <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>3.8.1</version>
    <scope>test</scope>
    </dependency>
</dependencies>
<build>
    <finalName>ProjectnameWARModule</finalName>
</build>
</project>

Following is the pom.xml for my JAR module - 以下是我的JAR模块的pom.xml

    <?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
    <groupId>Project_Name</groupId>
    <artifactId>Project_Name</artifactId>
    <version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>CADJARModule</groupId>
<artifactId>CADJARModule</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>CADJARModule</name>
<url>http://maven.apache.org</url>
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
    <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>3.8.1</version>
    <scope>test</scope>
    </dependency>
</dependencies>
</project>

Let me clarify: the dependencyManagement section provide dependencies governance to the same POM where it is defined and to children/modules Maven projects. 让我澄清一下: dependencyManagement部分为定义了该对象的同一个POM以及Maven项目的子代/模块提供依赖项治理。 However, declaring a dependency in the dependencyManagement section doesn't mean Maven will use it, it's just an hint in case Maven will use it so that if a certain version is missing in the dependencies section, Maven will look it up in the dependencyManagement section. 但是,在dependencyManagement部分中声明一个依赖项并不意味着Maven将使用它,它只是一个提示,以防万一Maven使用它,以便如果在dependencies部分中缺少某个版本,Maven将在dependencyManagement部分中查找它。 。 If none is found then, an error will be generated (Maven couldn't know which version to resolve for a certain dependency). 如果未找到,则将生成错误(Maven不知道要为某个依赖项解析哪个版本)。

Hence, good to have the dependencyManagement section for governance, but it should always define versions of each dependency, otherwise it would be a missed opportunity and make your build more error-prone. 因此,最好有用于管理的dependencyManagement部分,但是它应该始终定义每个依赖项的版本,否则将是错失良机,并使您的构建更容易出错。

If you need all of the declared dependencies and only in the scope of the same declaring POM, then you can actually avoid to have a dependenciesManagement section at all and just have your dependencies section providing versions for each declared dependency. 如果您需要所有已声明的依赖项,并且仅在相同的声明POM的范围内,那么实际上可以避免完全具有dependenciesManagement部分,而只让您的dependencies部分为每个声明的依赖项提供版本。

In this case, you are using a dependenciesManagement section in your parent POM (I see it has modules), you should then check if in the jar module the same dependency is declared (if required), otherwise it will not be used during its build. 在这种情况下,您正在父POM中使用dependenciesManagement部分(我看到它具有模块),然后应检查jar模块中是否声明了相同的依赖项(如果需要),否则在构建过程中将不使用它。 。 Moreover, you should also check whether another dependenciesManagement section is declared in the concerned module and re-declaring the same dependency again without version. 此外,您还应该检查是否在相关模块中声明了另一个dependenciesManagement部分,并再次重新声明相同的依赖项,而没有版本。

Some additional helps can be provided by: 可以通过以下方式提供一些其他帮助:

  • Running your Maven build using the -e -X flags 使用-e -X标志运行您的Maven构建
  • Running mvn dependency:tree -Dincludes=<concerned_group_id_here> 运行mvn dependency:tree -Dincludes=<concerned_group_id_here>
  • Last change option, run your build as mvn dependency:purge-local-repository clean install , which can work in case of corrupted cache (error should be different though) 最后一个更改选项,以mvn dependency:purge-local-repository clean install项的形式运行您的构建mvn dependency:purge-local-repository clean install ,它可以在缓存损坏的情况下工作(但错误应该有所不同)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 “未能执行目标 org.apache.maven.plugins:maven-jar-plugin:2.4:jar (default-jar)”为什么? - “Failed to execute goal org.apache.maven.plugins:maven-jar-plugin:2.4:jar (default-jar)” why? 无法执行目标 org.apache.maven.plugins:maven-jar-plugin:2.6:jar - Failed to execute goal org.apache.maven.plugins:maven-jar-plugin:2.6:jar 未能执行目标 org.apache.maven.plugins:maven-jar-plugin:3.1.2:jar (default-jar) - Failed to execute goal org.apache.maven.plugins:maven-jar-plugin:3.1.2:jar (default-jar) tools.jar问题无法执行目标org.apache.maven.plugins:maven-compiler-plugin - tools.jar issue Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin 无法执行目标 org.apache.maven.plugins:maven-archetype-plugin:2.4:generate - Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.4:generate A required class was missing while executing org.apache.maven.plugins:maven-jar-plugin:3.2.0:jar - A required class was missing while executing org.apache.maven.plugins:maven-jar-plugin:3.2.0:jar mvn安装本地jar错误:无法执行目标org.apache.maven.plugins:maven-install-plugin…(是目录)-&gt; [帮助1] - Error with mvn install local jar: Failed to execute goal org.apache.maven.plugins:maven-install-plugin…(Is a directory) -> [Help 1] 错误:路径必须包含项目和资源名称:/(org.apache.maven.plugins:maven-jar-plugin:2.4:jar:default-jar:package) - Error: Path must include project and resource name: / (org.apache.maven.plugins:maven-jar-plugin:2.4:jar:default-jar:package) 无法执行目标org.apache.maven.plugins:maven - Failed to execute goal org.apache.maven.plugins:maven 目标org.apache.maven.plugins执行attach-javadocs:maven-javadoc-plugin:3.0.0:jar使用Java10失败 - Execution attach-javadocs of goal org.apache.maven.plugins:maven-javadoc-plugin:3.0.0:jar failed with Java10
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM