Pri*_*nka 1 java spring maven spring-batch
我有一个java应用程序,我正在使用maven来加载依赖项.我的主要方法是在App.java中,还有其他各种类.这是一个基于弹簧的应用程序.我将使用批处理文件运行此应用程序.
这是我到目前为止所尝试的:
但我想知道是否还有其他办法可以达到同样的目的.在清单中我要给出所有罐子的名字
同样在应用程序jar中,会自动创建清单文件.所以我要手动编辑它以给出主类名和所有依赖的jar.
任何帮助赞赏.
谢谢.
使用Maven Jar插件来做你想要的.您可以将其配置为放置所有清单条目以满足您的需求.
<plugin>
<!-- jar plugin -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifestEntries>
<Main-Class>package.path.for.App</Main-Class>
<implementation-version>1.0</implementation-version>
</manifestEntries>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix> <!-- use this to specify a classpath prefix, in your case, lib -->
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
</manifest>
</archive>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
为了便于将所有依赖项复制到特定文件夹,请使用Maven依赖项插件:
<plugin>
<!-- copy all dependencies of your app to target folder-->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory> <!-- use this field to specify where all your dependencies go -->
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
<goals>
<goal>copy-dependencies</goal>
</goals>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1227 次 |
| 最近记录: |