java - 无法通过maven创建fat jar

标签 java maven maven-assembly-plugin fatjar

我正在尝试创建一个 fat jar 子,其中包含我的测试类以及此处的描述:How to add test classes in JAR with Maven project

但是当我运行 maven install 时出现以下错误:

Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.3:single (make-assembly) on project formulas: Failed to create assembly: Unable to resolve dependencies for assembly 'fat-tests': Failed to resolve dependencies for assembly: Missing:
[ERROR] ----------
[ERROR] 1) org.eclipse.jetty:jetty-servlet:jar:7.6.16
[ERROR] 
[ERROR]   Try downloading the file manually from the project website.
[ERROR] 
[ERROR]   Then, install it using the command: 
[ERROR]       mvn install:install-file -DgroupId=org.eclipse.jetty -DartifactId=jetty-servlet -Dversion=7.6.16 -Dpackaging=jar -Dfile=/path/to/file
[ERROR] 
[ERROR]   Alternatively, if you host your own repository you can deploy the file there: 
[ERROR]       mvn deploy:deploy-file -DgroupId=org.eclipse.jetty -DartifactId=jetty-servlet -Dversion=7.6.16 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]

Outout 很明显我丢失了 jar,但我不明白为什么我会面对它。

最佳答案

没有像 7.6.16 这样的版本用于 jetty-servlet 依赖项。确保您有一个正确的依赖项,例如:

<dependency>
    <groupId>org.eclipse.jetty</groupId>
    <artifactId>jetty-servlets</artifactId>
    <version>7.6.16.v20140903</version>
</dependency>

或者来自 Maven 中央存储库的以下任何版本: https://mvnrepository.com/artifact/org.eclipse.jetty/jetty-servlets

您还可以重命名本地 Maven 存储库中的文件夹和 jar,但我强烈建议您不要这样做,因为这只是一种 hack。

关于java - 无法通过maven创建fat jar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53813541/

相关文章:

Java 抽象类 - 实例变量应该是私有(private)的还是 protected ?

Eclipse 中新的 java maven 项目的 Javadoc

maven - 创建 '--rsyncable' maven 程序集

maven - 当 Maven 创建 zip 文件时,程序集 ID 被附加

java - Intellij idea,无法使Maven工作

maven - 如何在 mvn assembly :single? 期间关联 Ant 任务

java - GridBagLayout 单元格中对象的对齐方式

java - PlaceAutoCompleteFragment setHint NPE

java - 我们如何在 main 方法中通过其他方法更新 boolean 值

java - 使用maven构建时无法读取子包