Maven compilation error: package does not exist jar package does not exist

A compilation failure was encountered while using the Maven command MVN package to package. Maven prompted the compilation error: the package does not exist JAR package. After checking, it was the use of non-Maven repository jars in the project, i.e., the use of local jars, which caused Maven to compile without finding jars. The solution is to configure POm.XML to add the path to the local JAR so that Maven can identify and find the local JAR at compile time.

The configuration of the Maven-compiler-plugin in POM.xml is referred to below. The focus is on the configuration of the compilerArguments element. To add a native JAR package, just add a line to the compilerArguments element.

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

The pom.xml build configuration is referenced below.

<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>

Read More: