1.pom文件引入依赖
bash
<!-- https://mvnrepository.com/artifact/com.aspose/aspose-words -->
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-words</artifactId>
<version>18.6.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/aspose-words-18.6.0.jar</systemPath>
<type>jar</type>
<optional>true</optional>
</dependency>
2.系统lib包下放入外部jar包
3.pom文件修改打包代码,指定读取jar包
bash
<!-- 打包时候用 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.example.SpringbootInit</mainClass>
<addClasspath>true</addClasspath>
<classpathPrefix>lib</classpathPrefix>
</manifest>
<manifestEntries>
<!--读取外部配置文件,放到classpath里 -->
<Class-Path>resources/. lib/aspose-words-18.6.0.jar</Class-Path>
</manifestEntries>
</archive>
<outputDirectory>${project.build.directory}</outputDirectory>
<excludes>
<exclude>**/*.properties</exclude>
</excludes>
</configuration>
</plugin>
在打包的时候指定读取外部的jar包,这样部署到linux后,启动就不会报找不到jar包的错误了