关于自己在 pom.xml自己指定路径引用的jar包,如何在使用maven时将其打入自己的项目lib包中
1.在pom.xml文件中以这种方式引入jar包导致项目打包时无法将此包打入项目中
<dependencies>
<dependency>
<groupId>xxx</groupId>
<artifactId>xxx</artifactId>
<version>xxx</version>
<scope>system</scope>
<systemPath>${basedir}/xx.jar</systemPath>
</dependency>
</dependencies>
2.分两种情况打包 jar包和war包
2.1打成jar的形式(如springboot项目)
第一步在<plugins>标签中增加以下插件引入
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<groupId>com.arcsoft.face</groupId>
<artifactId>arcsoft-sdk-face</artifactId>
<version>3.0.0.0</version>
<packaging>jar</packaging>
<file>D:/XXX/XXX/arcsoft-sdk-face-3.0.0.0.jar</file>//pom.xml文件中引入的jar包
</configuration>
</execution>
</executions>
</plugin>
第二步将pom.xml文件中本地引入的依赖注释掉,执行以下maven的install命令将此jar包通过插件安装到maven中,
第三步在pom.xml注释的本地引入删除改为以下maven依赖方式引入
<dependency>
<artifactId>xxx</artifactId>
<groupId>xxx</groupId>
<version>xxx</version>
</dependency>
第四步执行打包命令,本地包就可以顺利打入项目的lib中。
2.1war包形式打包
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<webResources>
<resource>
<directory>D:/xxx/lib</directory>
<targetPath>WEB-INF/lib</targetPath>//根据自己情况调整路径
<filtering>false</filtering>
<includes>
<include>**/*.jar</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐


所有评论(0)