最近有个项目,要使用aliyun的vod功能,有一个VOD的上传功能,需要一个本地的jar包,maven库是没有的
maven加载本地jar包的设置比较简单,我在项目的根目录新增了libs文件夹,然后把jar包放在里面,pom.xml如下:
<dependency>
<groupId>com.aliyun.vod</groupId>
<artifactId>upload</artifactId>
<version>1.4.14</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/aliyun-java-vod-upload-1.4.14.jar</systemPath>
</dependency>
<dependency>
<groupId>com.aliyun.vod</groupId>
<artifactId>upload</artifactId>
<version>1.4.14</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/aliyun-java-vod-upload-1.4.14.jar</systemPath>
</dependency>
<dependency> <groupId>com.aliyun.vod</groupId> <artifactId>upload</artifactId> <version>1.4.14</version> <scope>system</scope> <systemPath>${project.basedir}/libs/aliyun-java-vod-upload-1.4.14.jar</systemPath> </dependency>
开发环境下springboot运行没有任何问题,但是打包后,上传到服务器上运行,就提示jar包里面用到的ClassNotFoundException了。
问题解决
最终研究后问题解决如下:
<project>
<dependencies>
<dependency>
<groupId>com.aliyun.vod</groupId>
<artifactId>upload</artifactId>
<version>1.4.14</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/aliyun-java-vod-upload-1.4.14.jar</systemPath>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<includeSystemScope>true</includeSystemScope>
</configuration>
<!-- must use 1.4.2 version -->
<version>1.4.2.RELEASE</version>
</plugin>
</plugins>
</build>
</project>
<project>
<dependencies>
<dependency>
<groupId>com.aliyun.vod</groupId>
<artifactId>upload</artifactId>
<version>1.4.14</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/aliyun-java-vod-upload-1.4.14.jar</systemPath>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<includeSystemScope>true</includeSystemScope>
</configuration>
<!-- must use 1.4.2 version -->
<version>1.4.2.RELEASE</version>
</plugin>
</plugins>
</build>
</project>
<project> <dependencies> <dependency> <groupId>com.aliyun.vod</groupId> <artifactId>upload</artifactId> <version>1.4.14</version> <scope>system</scope> <systemPath>${project.basedir}/libs/aliyun-java-vod-upload-1.4.14.jar</systemPath> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <includeSystemScope>true</includeSystemScope> </configuration> <!-- must use 1.4.2 version --> <version>1.4.2.RELEASE</version> </plugin> </plugins> </build> </project>
干货要点:
spring-boot-maven-plugin下的configuration增加:<includeSystemScope>true</includeSystemScope>
文章评论