MAVEN relies on local non-repository jar packages-dependencies on jar packages placed in directories such as Web-inf/lib client-side compilation error handling

Source: Internet
Author: User

MAVEN relies on a jar package in a local non-repository

Http://www.cnblogs.com/piaolingxue/archive/2011/10/12/2208871.html

Blog Category:
Maven
Today, when using a MAVEN compilation to package a Web application, you encounter a problem:
The project was developed with the introduction of a dependency jar package, placed in the Web-inf/lib directory, and the Web Libariary imported through BuildPath.
There is no problem with developing in eclipse, but using MAVEN to compile plug-ins is always a good time to find the classes in the jar package web-inf/lib.
Obviously when compiling the Web-inf/lib is not configured in the Maven-complier-plugin plugin src directory to go,
Then add this directory, or not. Rogue, first install this jar package in the local library and add dependency.

Later, Google found that Maven provided the scope for system dependency, the original document is as follows:
System
This "is" similar to provided except, which has to provide the JAR which contains it explicitly.
The artifact are always available and are not looked up in a repository.

This allows you to add dependency without having to install the jar package in the Web-inf/lib directory into your local library.
The specific configuration recorded:
XML code
<dependency>
<groupId>org.apache</groupId>
<artifactId>test</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${basedir}/src/main/webapp/WEB-INF/lib/paypal_base.jar</systemPath>
</dependency>

! A better way is to configure the compile parameter <compilerarguments>, and add extdirs to add the jar package relative path to the configuration as follows:

<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>UTF-8</encoding>
<compilerArguments>
<extdirs>src\main\webapp\WEB-INF\lib</extdirs>
</compilerArguments>
</configuration>
</plugin>
</plugins>
</build>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.