添加到DataNucleus答案。
为了满足您的需求,您应该使用 maven-dependency-plugin
并将以下内容添加到pom.xml中
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>2.4</version> <executions> <execution> <id>copy-dependencies</id> <phase>package</phase> <goals> <goal>copy-dependencies</goal> </goals> <configuration> <outputDirectory>${project.build.directory}/jars</outputDirectory> <overWriteReleases>false</overWriteReleases> <overWriteSnapshots>false</overWriteSnapshots> <overWriteIfNewer>true</overWriteIfNewer> </configuration> </execution> </executions> </plugin> </plugins></build>然后,依赖项将位于 target / jars 目录中。
要执行您的应用程序,请使用以下命令:
Windows:
java -cp“ yourFile.jar; jars / *” package.className
Linux:
java -cp“ yourFile.jar:jars / *” package.className
注意:请勿使用jars / * .jar,这将无法正常工作



