[英]NoClassDefFoundError on Maven dependency present locally
I am new to Maven Project. 我是Maven项目的新手。 I am making changes to one of the open source maven project.
我正在对开源maven项目之一进行更改。 I am facing a problem in adding a library to the project.
我在向项目添加库时遇到问题。 So far i have done this :-
到目前为止,我已经做到了:-
Then in the pom.xml i added:- 然后在pom.xml中添加:
<dependency> <groupId>jar.0.8.8.0.jni4net</groupId> <artifactId>jar.0.8.8.0.jni4net</artifactId> <version>0.8.8.0</version> <scope>system</scope> <systemPath>${basedir}/src/main/resources/jni4net.j- 0.8.8.0.jar</systemPath> </dependency>
But when i build this project(build is successful, test cases are running) and use this it throws following error:- 但是当我构建这个项目(构建成功,测试用例正在运行)并使用它时,它会引发以下错误:-
java.lang.NoClassDefFoundError: net/sf/jni4net/Bridge
Please help me resolve it. 请帮我解决。 I am new to maven and pom.
我是Maven和Pom的新手。 I have looked at various answers, but not getting it right.
我已经看过各种答案,但并没有正确回答。 PS - I named groupId and artifactID as just reverse of jar file
PS-我将groupId和artifactID命名为jar文件的反向
This is not the right way to add that dependency. 这不是添加依赖项的正确方法。
All you need is: 所有你需要的是:
<dependency>
<groupId>net.sf.jni4net</groupId>
<artifactId>jni4net.j</artifactId>
<version>0.8.8.0</version>
</dependency>
The dependency will be retrieved from Maven Central when you build. 构建时将从Maven Central检索依赖项。
Using <systemPath>...</systemPath>
is highly discouraged as it usually ties your project to a local environment. 不建议使用
<systemPath>...</systemPath>
因为它通常将您的项目与本地环境联系在一起。
Since jni4net.j dependency is available in maven central, You don't have to download and put the dependency manually. 由于jni4net.j依赖关系在maven Central中可用,因此您不必手动下载并放置依赖关系。 Maven will download and store the dependency locally in `'.m2' folder.
Maven将在本地将依赖项下载并存储在“ .m2”文件夹中。 Just add dependency as bellow.
只需添加依赖项即可。
<dependency>
<groupId>net.sf.jni4net</groupId>
<artifactId>jni4net.j</artifactId>
<version>0.8.8.0</version>
</dependency>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.