The*_*tor 27
在你的pom.xml文件中......
1)将此代码添加到project-> properties节点.这将在一个中心位置定义您的主类,以便在许多插件中使用.
<properties>
<mainClass>project.Main.class</mainClass>
</properties>
Run Code Online (Sandbox Code Playgroud)
2)将此代码添加到project-> build-> plugins节点.它会将所有jar依赖项收集到lib文件夹中,并使用正确的类路径引用编译主类jar:
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>${mainClass}</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14155 次 |
| 最近记录: |