在maven构建期间找不到外部jar的类文件? [英] Class file from a external jar not found during maven build?

查看:956
本文介绍了在maven构建期间找不到外部jar的类文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个可运行的jar,我将其包含在我的项目中(Maven Project)。
但是当我尝试做mvn clean包时。我的构建失败它在我的一个类导入中给出了一个错误,指出该包不存在(在jar中存在)。

I have created a runnable jar which i included in my project(Maven Project). But when i tried doing mvn clean package. My build gets failed It gives me an error in one of my class imports stating that the package does not exist(which is present in jar).

我尝试了什么:


  1. 尝试在Web App Libraries中添加jat。

  2. 将jar添加为外部jar。

  3. 将其添加到lib文件夹中。

错误消息:

 Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project interplan: Compilation failure: Compilation failure:
[ERROR] ..\..\..\MyVehicles.java:[11,40] error: package com.vehicles.parts.manager does not exist

请指导。在此先感谢。

推荐答案

您需要安装外部jar 本地存储库的方式如下:

You need to install your external jar in local repository in following way:

mvn install:install-file -Dfile=c:\kaptcha-{version}.jar -DgroupId=com.google.code -DartifactId=kaptcha -Dversion={version} -Dpackaging=jar

并在pom中添加以下依赖项:

and add the following dependency in pom:

<dependency>
      <groupId>com.google.code</groupId>
      <artifactId>kaptcha</artifactId>
      <version>2.3</version>
 </dependency>

请替换外部jar的值对于 c:\kaptcha- {version} .jar

再次构建并告诉我结果。

Build again and tell me the result.

您还可以查看 http://www.mkyong.com/maven/how-to-include-library-manully-into-maven-local-repository/

这篇关于在maven构建期间找不到外部jar的类文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆