【发布时间】:2014-05-23 13:36:54
【问题描述】:
为了与 m2e 错误/问题保持一致,我遵循了提到的解决方案 @SL4j m2e fails to load in Eclipse IDE。
我的 Pom.xml 看起来像这样(对于我的 JUnit 和 Selenium 依赖项):
<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>TestJUnit</groupId>
<artifactId>TestJUnit</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<type>jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.41.0</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.10-FINAL</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>2.41.0</version>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>1.3</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
但是,当我执行mvn compile 时,会出现以下错误:
[ERROR] /path:/to/file/<foldername>/<JUnitClassName>.java:[9,17] package org.junit does
not exist
我是 maven 新手,我在这里做错了什么吗?
【问题讨论】:
-
你能在eclipse中打开调试器的情况下运行命令吗?看起来junit jar没有正确下载或junit版本在m2中崩溃。你可以谷歌如何在eclipse中调试选项
-
您是否在位于“main”包中的类中使用 JUnit? stackoverflow.com/questions/12403497/…
-
@Trichoko 感谢您的指出。问题是因为我使用了
test 。当我根据下面提供的解决方案解决了这个问题时,我可以解决这个问题。
标签: java eclipse maven selenium junit