In project development, the project is managed by Maven and is a MAVEN project.
In general, jar packages can use Pom.xml to configure management, but there are times when we use an internal jar file in our project, but this file is not open to the MAVEN repository.
We will take the file to our project Web-inf/lib.
If we do not have a special configuration for Pom.xml, MAVEN packaging does not automatically refer to and compile the Lib jar file, so we need to modify the next Pom.xml file.
Modify the configuration of the Maven-compiler-plugin as follows:
<plugin> <groupId>Org.apache.maven.plugins</groupId> <artifactid>Maven-compiler-plugin</artifactid> <version>3.1</version> <configuration> <source>1.7</Source> <target>1.7</target> <encoding>UTF-8</encoding> <compilerarguments> <verbose /> <bootclasspath>${env. Java_home}/jre/lib/rt.jar</bootclasspath> <extdirs>Src/main/webapp/web-inf/lib</extdirs> </compilerarguments> </configuration></plugin>
The other configuration is my original configuration, for LIB reference this problem, only need to add is:
<extdirs>src/main/webapp/WEB-INF/lib</extdirs>
Another popular science, maven directory contract:
The directory where the Pom.xml is located should be the root of the project, assuming the directory is ${proj-dir}, then Maven has the following assumptions:
${proj-dir}/src/main/java--. java files that store the project.
${proj-dir}/src/main/resources--Store project resource files, such as spring, hibernate configuration files.
${proj-dir}/src/test/jave--store all test. java files, such as JUnit test classes.
${proj-dir}/src/test/resources--the test resource file.
${proj-dir}/target--the project output location.
Run a MVN clean Package command, MAVEN will help you clear the target directory, re-build an empty, compile Src/main/java class to target/classes, copy src/main/ Resources files to target/classes, compiling Src/test/java to target/test-classes, copying src/test/resources files to target/test-classes ; then run all the tests; After the test passes, it is packaged with the jar command and stored in the target directory. Maven does a lot of things, but all the users are hidden, it only requires you to follow its convention.
Finish
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Using MAVEN to compile and use the jar package under Lib