idea中maven引入第三方jar 打包报错:' dependencies.dependency.version' for xxx:jar is missing. @ Line 105, column 21
最近公司要对接海康威视的人脸接口,拿到文档研究了一下,老规矩先导入外部开发包项目为springboot web项目,创建lib文件夹,将需要用到的jar包丢进去。
lib下这两个包是需要外部引用的jar包;
然后再 pom.xml 中添加配置,来引入lib中的jar包
<!-- 引入海康威视SDK -->
<dependency>
<groupId>cn.hk</groupId>
<artifactId>examples</artifactId>
<scope>system</scope>
<systemPath>${pom.basedir}/lib/examples.jar</systemPath>
</dependency>
<dependency>
<groupId>cn.hk</groupId>
<artifactId>jna</artifactId>
<scope>system</scope>
<systemPath>${pom.basedir}/lib/jna.jar</systemPath>
</dependency>
然后再plugins 中的maven打包插件加入 true
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>
部署配置好后,运行没有问题。
当代码敲完准备打包部署的时package报错dependenc ies . dependency . version’ for cn. hk: exampLes:jar is missing. @ Line 105, column 21
dependencies . dependency . version’ for cn.hk:jna:jar is missing. @ line 111, column 21
这里是因为 jar包名称没有添加版本号 maven打包时版本不确定
修改jar包名称 :
然后依赖中添加对应的版本号信息
<dependency>
<groupId>cn.hkws</groupId>
<artifactId>examples</artifactId>
<scope>system</scope>
<version>1.0</version>
<systemPath>${pom.basedir}/lib/examples-1.0.jar</systemPath>
</dependency>
<dependency>
<groupId>cn.hkws</groupId>
<artifactId>jna</artifactId>
<scope>system</scope>
<version>1.0</version>
<systemPath>${pom.basedir}/lib/jna-1.0.jar</systemPath>
</dependency>
再重新打包测试:
打包成功