以项目中用到的 aspose-words-20.3-jdk17.jar 为例:
1. 下载jar包
2.在项目目录下新建“lib”文件夹,并将需要引入的jar导入
**3.修改pom,增加、配置 **
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-words</artifactId>
<version>${aspose.version}</version>
<scope>system</scope>
<systemPath>${pom.basedir}/lib/aspose-words-20.3-jdk17.jar</systemPath>
</dependency>
4.spring 打包后启动如果出现以下错误:
Caused by: java.lang.ClassNotFoundException: com.aspose.words.Document
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:151)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
... 46 common frames omitted
原因:引入的本地jar包没有被打进去
解决:pom中配置includeSystemScope属性
例如:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<!--设置为true,以便把本地的system的jar也打进去-->
<includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>
</plugins>
</build>