The project requires the use of MAVEN's packaging tools to generate a zip archive, using a plugin that is assembly-plugin. For some special reasons, it is necessary to use some local jar to rely on, and after loading the external jar there is no problem in the encoding process, but it has been reported that "package does not exist".
Think about it: MAVEN is essentially a plug-in framework, and its core does not perform any specific build tasks, so while the project is normally dependent on the development process without any problems, the local jar must not be found when it is packaged.
There are many solutions to this problem, such as joining a local warehouse, setting up a Maven, and so on, if you need these solutions, Google Baidu, a lot of information.
Because the MAVEN compiler uses the plug-in is Maven-compiler-plugin, so can only find the problem on the maven-compiler-plugin, the normal maven-compiler-plugin simple configuration is as follows:
<plugin> <groupId>Org.apache.maven.plugins</groupId> <Artifactid>Maven-compiler-plugin</Artifactid> <Configuration> <Source>1.8</Source> <Target>1.8</Target> <encoding>UTF-8</encoding> </Configuration></plugin>
If you need to rely on the local jar when packaging, you need to modify the configuration to add the following:
<plugin> <groupId>Org.apache.maven.plugins</groupId> <Artifactid>Maven-compiler-plugin</Artifactid> <Configuration> <Source>1.8</Source> <Target>1.8</Target> <encoding>UTF-8</encoding> <compilerArguments> <extdirs>${project.basedir}/src/lib</extdirs> </compilerarg Uments> </Configuration></plugin>
If you are using a MAVEN version higher than 3.1, the above configuration has been deprecated and needs to be modified as follows:
<plugin> <groupId>Org.apache.maven.plugins</groupId> <Artifactid>Maven-compiler-plugin</Artifactid> <Configuration> <Source>1.8</Source> <Target>1.8</Target> <encoding>UTF-8</encoding> <compilerArgs> <arg>-extdirs</arg> <arg>${project.basedir}/src/lib< /arg> </compilerArgs> </Configuration></plugin>
Note that it is best to add ${project.basedir} for better compatibility.
Modified the above compiled plug-in, packaging normal, no longer an error, but there is a new problem arises. The generated zip package does not contain a dependent local jar.
Modify the configuration file of the Maven-assembly-plugin plugin to add the following configuration:
< Fileset > < Directory >src\lib</directory> <OutputDirectory >lib</outputdirectory></fileset >
It means to output the jar under the src\lib to the target root lib.
At this point, using the MAVEN Package command, it has been able to run properly and successfully put the local jar packet into the zip archive directory.
MAVEN package contains local jar