maven打包引入本地依赖

问题

在项目中引用了第三方jar包,使用maven给程序打包时,如果不指定jar路径就会显示丢失依赖

解决方法

在pom.xml中添加如下插件,并指明jar包路径

<plugin>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
        <source>1.8</source>
            <target>1.8</target>
            <encoding>UTF-8</encoding>
            <compilerArguments>
                <extdirs>${project.basedir}/lib</extdirs>
            </compilerArguments>
    </configuration>
</plugin>

注意:一定要指明具体路径 ${project.basedir},否则会找不到路径

另一个解决方式,指明本地jar路径


<!--根据本地仓库进行配置-->
<dependency>
    <groupId>com.jar</groupId>
    <artifactId>redmine_ejb</artifactId>
    <version>0.0.0</version>
    <scope>system</scope>
    <systemPath>${project.basedir}/lib/redmine_ejb.jar</systemPath>
</dependency>
posted @ 2022-04-03 17:22  胡鹏飞  阅读(341)  评论(0)    收藏  举报