JavaEar 专注于收集分享传播有价值的技术资料

不能包括项目神器:com.test.mmm.jar:1.0;它并没有相关的文件或目录 (Cannot include project artifact: com.test.mmm.jar:1.0; it doesn't have an associated file or directory)

I'm pretty lost with maven and I can't seem to find a solution for my problem. When I try to generate the jar file with all the dependencies of my project to execute it on another computer I find this warning when I execute sudo mvn clean compile assembly:single:

[WARNING] Cannot include project artifact: com.test:mmm:jar:1.0; it doesn't have an associated file or directory.

Also, when I try to execute the .jar with java -jar target/test.jar this error appears:

Error: Unable to access jarfile target/test.jar

here's my 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.test</groupId>
<artifactId>mmm</artifactId>
<version>1.0</version>
<packaging>jar</packaging>

<name>mmm</name>
<url>http://maven.apache.org</url>
<properties>
    <nd4j.backend>nd4j-cuda-8.0-platform</nd4j.backend>
</properties>

<dependencies>
    <dependency>
        <groupId>org.jblas</groupId>
        <artifactId>jblas</artifactId>
        <version>1.2.4</version>
    </dependency>
    <dependency>
        <groupId>org.nd4j</groupId>
        <artifactId>nd4j-native-platform</artifactId>
        <version>0.8.0</version>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.8.2</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.deeplearning4j</groupId>
        <artifactId>deeplearning4j-core</artifactId>
        <version>0.8.0</version>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>3.0.0</version>
            <configuration>
                <archive>
                    <manifest>
                        <mainClass>com.test.mmm.Main</mainClass>
                    </manifest>
                </archive>
                <finalName>test</finalName>
                <descriptorRefs>jar-with-dependencies</descriptorRefs>
            </configuration>
        </plugin>
    </plugins>
</build>

The main class is located in src/ I've tried many solutions from stack overflow but had no success, can someone help me?

Thank you!

1个回答

    最佳答案

  1. 英文原文

    Use mvn package first to build your module classes then assembly:single.

    mvn package assembly:single


    中文翻译

    使用 MVN包第一建立你模块类然后组件:单

    MVN封装组件:单

    Use mvn package first to build your module classes then assembly:single.

    mvn package assembly:single

    使用 MVN包第一建立你模块类然后组件:单

    MVN封装组件:单