【转】解决maven无法加载本地lib/下的jar包问题(程序包XXX不存在)

原文链接:https://www.cnblogs.com/adeng/p/7096484.html

这次一个项目用到maven编译,我在本地开发的时候jar包都是放在WEB-INF/lib目录下,通过
 
BuildPath将jar包导入,然后用MyEclipse中的:maven package命令打成war包,这个war包在tomcat下能正常运行,war包下是有lib下的jar包的。

通过IDEA自带的运行能够正常识别lib包下的jar,但是我要是通过maven profile实现多环境配置自动分离 则会出现“程序包xxx不存在的”错误

若该程序包是jdk自带的程序包,请参照:解决maven编译错误:程序包com.sun.xxx不存在

若该程序包是第三方的jar,解决方案是让maven既加载maven库中的jar包,又要加载本地WEB-INF/lib下的jar包。

现在终于解决问题了,方法是在pom.xml文件中添加一段配置:

复制代码
      <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.6.0</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <encoding>UTF-8</encoding>
                    <compilerArguments>
                        <extdirs>${project.basedir}/src/main/webapp/WEB-INF/lib</extdirs>
                    </compilerArguments>
                </configuration>
            </plugin>

<wiz_tmp_tag id="wiz-table-range-border" contenteditable="false" style="display: none;">

posted @ 2019-10-22 14:40  AaronPi  阅读(1017)  评论(0编辑  收藏  举报