gpt4 book ai didi

java - 无法执行目标 org.apache.maven.plugins :maven-jar-plugin:2. 4:jar

转载 作者:行者123 更新时间:2023-11-30 07:45:20 25 4
gpt4 key购买 nike

因此,我尝试继续为现有的 maven 项目创建一个 .ear 文件,并将其进一步部署在 WebLogic 服务器 上。同样,我继续创建 WARJAREAR 模块,并按照以下步骤操作 -

父项目上右键,选择new,选择maven module,命名为 projectnameJARModule,然后完成向导

创建 projectnameWARModuleprojectnameEARModule 模块的过程相同。制作完成后,我将 WARJAR 模块作为 依赖项 添加到 EAR 模块。此外,我继续通过在 projectnameWARModule 文件夹上右键单击来安装 maven 模块,并选择Run As - Maven Install 。在此之后,我在控制台中收到以下错误(下面是完整的控制台日志) -

<小时/>
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

知道如何摆脱这个吗?非常感谢

以下是父模块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>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>

以下是 WAR 模块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>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>

以下是我的 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>

最佳答案

让我澄清一下:dependencyManagement部分为定义它的同一 POM 以及子/模块 Maven 项目提供依赖关系治理。但是,在 dependencyManagement 中声明依赖项部分并不意味着 Maven 将使用它,它只是一个提示,以防 Maven 将使用它,以便如果 dependencies 中缺少某个版本。部分,Maven 将在 dependencyManagement 中查找它。部分。如果没有找到,则会生成错误(Maven 无法知道要解析某个依赖项的版本)。

因此,很高兴拥有 dependencyManagement管理部分,但它应该始终定义每个依赖项的版本,否则将错失机会并使您的构建更容易出错。

如果您需要所有声明的依赖项,并且仅在同一声明 POM 的范围内,那么您实际上可以避免 dependenciesManagement完全部分,只需拥有您的 dependencies为每个声明的依赖项提供版本的部分。

在本例中,您使用的是 dependenciesManagement在你的父 POM 中的部分(我看到它有模块),然后你应该检查 jar 模块中是否声明了相同的依赖项(如果需要),否则在构建过程中将不会使用它。此外,您还应该检查是否有另一个 dependenciesManagement部分在相关模块中声明,并在没有版本的情况下再次重新声明相同的依赖项。

可以通过以下方式提供一些额外的帮助:

  • 使用 -e -X 运行 Maven 构建标志
  • 正在运行 mvn dependency:tree -Dincludes=<concerned_group_id_here>
  • 最后一个更改选项,运行您的构建 mvn dependency:purge-local-repository clean install ,这可以在缓存损坏的情况下工作(尽管错误应该不同)

关于java - 无法执行目标 org.apache.maven.plugins :maven-jar-plugin:2. 4:jar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34021575/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com