Maven compilation error : package does not exist jar 程序包不存在

使用 Maven 命令 mvn package 打包时遇到了编译失败的问题。Maven 提示 compilation error : package does not exist jar 程序包不存在。经查,是在项目使用了非 Maven 仓库的 jar 包,即使用了本地 jar 包,导致 Maven 编译时找不到 jar 包。解决办法是配置 pom.xml ,将本地 jar 包的路径添加到其中,使得 Maven 在编译时能够识别并找到本地 jar 包。


pom.xml 中 maven-compiler-plugin 的配置参考如下。重点是 compilerArguments 元素的配置,将本地的 jar 包添加进来,只需在 compilerArguments 中添加一行语句。


<compilerArguments>

<extdirs>${project.basedir}/src/main/webapp/WEB-INF/lib</extdirs>

</compilerArguments>


pom.xml 构建配置参考如下。

<build>
		<finalName>test</finalName>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<configuration>
					<source>1.8</source>
					<target>1.8</target>
					<compilerArguments>
					<extdirs>${project.basedir}/src/main/webapp/WEB-INF/lib</extdirs>
					</compilerArguments>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-surefire-plugin</artifactId>
				<configuration>
					<skipTests>true</skipTests>
					<testFailureIgnore>true</testFailureIgnore>
				</configuration>
			</plugin>
		</plugins>
</build>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值