springboot项目打包到服务器运行时的错误
- java.lang.ClassNotFoundException: org.opencv.imgcodecs.Imgcodecs
我在打包一个使用opencv库的项目运行时发现这个错误,在工程pom文件中添加如下两句就行了
<includeSystemScope>true</includeSystemScope><!--重要-->
<executable>true</executable><!--重要-->
完整的build配置如下:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.test.cc.ccMainApplication</mainClass>
<includeSystemScope>true</includeSystemScope><!--重要-->
<executable>true</executable><!--重要-->
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal><!--可以把依赖的包都打包到生成的Jar包中-->
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>