项目中用到本地jar和maven,java -jar 提示没有主清单
1、项目中依赖本地包
<dependency>
<groupId>aspose-words</groupId>
<artifactId>aspose-words-jdk16</artifactId>
<version>14.9.0</version>
<scope>system</scope>
<systemPath>${base.lib.path}/aspose-words-jdk16-14.9.0.jar</systemPath>
</dependency>
2、build:
<build>
<plugins>
<!-- 将所依赖的第三方jar包打入target下的lib目录 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${base.lib.path}</outputDirectory>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<!-- 打jar包的main方法配置 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>com.cz.mhm.App</mainClass>
</manifest>
<!-- 给清单文件添加键值对(配置文件外置) -->
<manifestEntries>
<Class-Path>main/resources/app.properties lib/aspose-words-jdk16-14.9.0.jar</Class-Path>
</manifestEntries>
</archive>
<!--打包的时候忽略classes 路径下的配置文件 -->
<!--<excludes>
<exclude>*.properties</exclude>
<exclude>*.xml</exclude>
<exclude>*.txt</exclude>
<exclude>templates/**</exclude>
</excludes>-->
</configuration>
</plugin>
</plugins>
</build>
3、Lifecycle中 package即可
标签:lib,jdk16,jar,maven,words,aspose,打包 From: https://blog.51cto.com/u_21817/6066944