您的位置:首页 > 其它

maven依赖本地非repository中的jar包-依赖jar包放在WEB-INF/lib等目录下的情况客户端编译出错的处理

2014-08-20 12:11 549 查看
maven依赖本地非repository中的jar包
http://www.cnblogs.com/piaolingxue/archive/2011/10/12/2208871.html
博客分类:
MAVEN
今天在使用maven编译打包一个web应用的时候,碰到一个问题:
项目在开发是引入了依赖jar包,放在了WEB-INF/lib目录下,并通过buildpath中将web libariary导入。
在eclipse中开发没有问题,但是使用maven编译插件开始便宜总是报找不到WEB-INF/lib这个jar包中的类。
显然实在编译的时候WEB-INF/lib并没有配置到maven-complier-plugin插件src目录中去,
于是将这个目录添加进去,还是不好使。无赖,先把这个jar包安装到本地库中,然后添加dependency。

后来google了下,发现maven提供了scope为system的依赖,文档的原文如下:
system
This scope is similar to provided except that you have to provide the JAR which contains it explicitly.
The artifact is always available and is not looked up in a repository.

这样就可以添加dependency而不需要再将WEB-INF/lib目录下的jar包安装到本地库中了。
具体配置录下:
Xml代码
<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>

!更好的方式是配置编译参数<compilerArguments>,添加extdirs将jar包相对路径添加到配置中,如下:

<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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐