Maven项目引用本地jar包依赖打包警告Some problems were encountered while building the effective model for com.xxx.xxx:xxx-xxx:jar should not point at files within the project directory
导入本地包WARNING警告的配置如下:
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-cad</artifactId>
<version>19.9</version>
<scope>system</scope>
<!-- WARNING警告点 -->
<systemPath>${project.basedir}/lib/aspose-cad-19.9.jar</systemPath>
</dependency>
<dependency>
<groupId>cpdetector</groupId>
<artifactId>cpdetector</artifactId>
<version>1.04</version>
<scope>system</scope>
<!-- WARNING警告点 -->
<systemPath>${project.basedir}/lib/cpdetector-1.04.jar</systemPath>
</dependency>
警告信息:
Some problems were encountered while building the effective model for com.xxx.xxx:xxx-xxx:jar:3.3.0
'dependencies.dependency.systemPath' for com.aspose:aspose-cad:jar should not point at files within the project directory, ${project.basedir}/lib/aspose-cad-19.9.jar will be unresolvable by dependent projects @ line 177, column 25
'dependencies.dependency.systemPath' for cpdetector:cpdetector:jar should not point at files within the project directory, ${project.basedir}/lib/cpdetector-1.04.jar will be unresolvable by dependent projects @ line 185, column 25
It is highly recommended to fix these problems because they threaten the stability of your build.
For this reason, future Maven versions might no longer support building such malformed projects.
大概意思是:
在打包时com.xxx.xxx:xxx-xxx:jar:3.3.0遇到了一些问题,‘dependencies.dependency.systemPath’下的com.aspose:aspose-cad:jar不应该指向项目目录。
在177行25列${project.basedir}/lib/aspose-cad-19.9.jar将无法解析依赖。
在185行25列${project.basedir}/lib/cpdetector-1.04.jar将无法解析依赖。
强烈建议修复这些问题,因为它们威胁到构建的稳定性。
因为在未来的Maven版本可能不再支持构建这种格式错误的项目。
报了这个警告但是包都能正常打进去,网上有人说打不进去,按照网上的方式包反而打不进去了。
搜到的解决方式参见:https://blog.csdn/asing1elife/article/details/82732113
解决方案:
1.去掉<scope>
、<systemPath>
标签,即改为:
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-cad</artifactId>
<version>19.9</version>
</dependency>
<dependency>
<groupId>com.cpdetector</groupId>
<artifactId>cpdetector</artifactId>
<version>1.04</version>
</dependency>
2.使用插件导入本地jar包,这里有提供2种方式:
第一种方式,使用spring-boot-maven-plugin
插件:
关键配置<argument>${project.basedir}\lib</argument>
导入lib下的所有jar包
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<arguments>
<argument>${project.basedir}\lib</argument>
</arguments>
</configuration>
</plugin>
第二种方式,使用maven-compiler-plugin
插件:
关键配置<extdirs>${project.basedir}\lib</extdirs>
导入lib下的所有jar包
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
<optimize>true</optimize>
<!-- 导入\lib下的本地jar包 -->
<compilerArguments>
<extdirs>${project.basedir}\lib</extdirs>
</compilerArguments>
</configuration>
</plugin>
优点:
1.解除了以上打包警告。
2.可以单个导入jar包,如果本地jar依赖比较多,也可以直接导入\lib
目录下的所有jar包。
缺点:
1.引入了新的插件(可以忽略)。
2.待补充······
更多推荐
Maven项目引用本地jar包依赖打包警告should not point at files within the project directory
发布评论