具有依赖项的Jar不包含我自己的依赖项

时间:2019-06-03 11:45:19

标签: java maven jar

我创建了一个简单的应用程序并将其构建为独立的jar-运行正常。现在,我正在开发另一个应用程序,并且想使用上一个应用程序的功能,因此我尝试将其作为对我新项目的依赖项。

这是我的pom.xml

<dependencies>
    <dependency>
        <groupId>com.johndoe</groupId>
        <artifactId>my-tool</artifactId>
        <version>1.0-SNAPSHOT</version>
        <scope>system</scope>
        <systemPath>
            ${basedir}/dependencies/my-tool-1.0-SNAPSHOT-jar-with-dependencies.jar
        </systemPath>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <configuration>
                <archive>
                    <manifest>
                        <mainClass>com.johndoe.anothertool.Main</mainClass>
                    </manifest>
                </archive>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
            </configuration>
            <executions>
                <execution>
                    <id>make-assembly</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

只要我从IDE运行它,它就可以正常工作。但是,在将我的新应用程序构建到*.jar并运行后,我得到

  

线程“主”中的异常java.lang.NoClassDefFoundError:   com / johndoe / my-tool / MyToolAPI

当然,IV将dependencies文件夹添加到与jar相同的位置

enter image description here

0 个答案:

没有答案