maven错误:包org.junit不存在 [英] maven error: package org.junit does not exist

查看:1323
本文介绍了maven错误:包org.junit不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试用maven创建javadoc但它失败了。执行验证时也会失败。

I'm trying to create the javadoc with maven and it fails. It also fails when doing the verify.

mvn verify

我收到以下错误:

(...)
    [INFO] -------------------------------------------------------------
    [ERROR] COMPILATION ERROR : 
    [INFO] -------------------------------------------------------------
    [ERROR] /home/miquel/creaveu/createOmegaMatrix/src/main/java/edu/url/salle/gtm/hnm/dataStructures/HFrame.java:[6,23]
package org.junit does not exist
    [ERROR] /home/miquel/creaveu/createOmegaMatrix/src/main/java/edu/url/salle/gtm/hnm/dataStructures/HFrame.java:[6,0]
static import only from classes and interfaces
    (···)

在我的pom.xml文件中,我有以下内容行:

In my pom.xml file I have the following lines:

<dependency>
  <groupId>org.junit</groupId>
  <artifactId>junit</artifactId>
  <version>4.8.2</version>
  <scope>test</scope>
</dependency>

我的本​​地存储库包含junit jar文件:

and my local repository contains the junit jar file:

miquel@ubuntu:~/creaveu/createOmegaMatrix$ ls -l /home/miquel/.m2/repository/org/junit/junit/4.8.2/
total 248
**-rw-r--r-- 1 miquel miquel 237344 2012-09-13 11:01 junit-4.8.2.jar**
-rw-r--r-- 1 miquel miquel    236 2012-09-13 11:13 junit-4.8.2-javadoc.jar.lastUpdated
-rw-r--r-- 1 miquel miquel      0 2012-09-13 11:13 junit-4.8.2-javadoc.jar-not-available
-rw-r--r-- 1 miquel miquel    458 2012-09-12 18:35 junit-4.8.2.pom
-rw-r--r-- 1 miquel miquel    236 2012-09-13 11:13 junit-4.8.2-sources.jar.lastUpdated
-rw-r--r-- 1 miquel miquel      0 2012-09-13 11:13 junit-4.8.2-sources.jar-not-available
-rw-r--r-- 1 miquel miquel    163 2012-09-13 11:22 _maven.repositories
miquel@ubuntu:~/creaveu/createOmegaMatrix$

代码很好,因为在我的笔记本电脑中,我现在没有访问权限,我跑道:

The code is fine because in my laptop, which I have no access now, I van run:

mvn javadoc:javadoc
mvn verify

没有问题,而且测试也在eclipse IDE中工作。

with no problems, and also the tests work in eclipse IDE.

推荐答案

好的,你已经宣布 junit 依赖于 test 类(那些在 src / test / java 但是你试图在 main 类(那些在 src / main / java 中)使用它。

Ok, you've declared junit dependency for test classes only (those that are in src/test/java but you're trying to use it in main classes (those that are in src/main/java).

要么不在主类中使用它,要么删除< scope> test< / scope>

Either do not use it in main classes, or remove <scope>test</scope>.

这篇关于maven错误:包org.junit不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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