我是Maven的新手,所以如果这太基本了,请原谅我。我已经搜索了这个问题,每个人似乎都解决了从pom.xml文件中移除标签的问题。Maven:包org.junit不存在
我没有这个标签有:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>GraphApp</groupId>
<artifactId>GraphApp</artifactId>
<version>1.0.0</version>
<name>MyApp</name>
<description>MyApp</description>
<build>
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>test</testSourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
我已经转换与Eclipse现有的项目,所以这个问题可能来自。
此外,我已经读过,Maven的默认架构是将代码存储在某些默认文件夹中,而我使用的是src/com/romanrdgz/core/myapp
和/test/com/romanrdgz/test/core
。这也可能是问题的根源。
我看到这个错误:
Maven: package org.junit does not exist
我需要做什么改变吗?
编辑:好吧,我已经包含JUnit4的依赖性,我也改变了我的文件夹是这样的:
不过,当我去安慰和执行mvn test
或mvn compile
,我得到的以下输出:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building GraphApp 1.0.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ GraphApp -
--
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources,
i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Users\rrrp\workspace\GraphApp\src\
main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ GraphApp ---
[INFO] Nothing to compile - all classes are up to date
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.515 s
[INFO] Finished at: 2015-04-15T08:15:06+02:00
[INFO] Final Memory: 11M/309M
[INFO] ------------------------------------------------------------------------
我试过擦除bin和目标文件夹,但仍然是相同的。看起来它没有找到类和测试。
任何帮助?
请张贴实际的堆栈跟踪。 – beerbajay
将junit依赖关系添加到pom – Reimeus
@Reimeus尝试过,但eclipse将其显示为错误。我应该在哪里添加它? –