当前位置: 代码迷 >> J2EE >> eclipse创造maven工程以后,测试代码找不到junit.jar包
  详细解决方案

eclipse创造maven工程以后,测试代码找不到junit.jar包

热度:103   发布时间:2016-04-17 23:32:37.0
eclipse创建maven工程以后,测试代码找不到junit.jar包
本帖最后由 u012995733 于 2014-11-01 01:05:40 编辑
maven工程的buildpath里有junit3.8.1.jar包,但是eclipse提示找不到

<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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>maven_test</groupId>
  <artifactId>maven1</artifactId>
  <packaging>war</packaging>
  <version>0.0.1-SNAPSHOT</version>
  <name>maven1 Maven Webapp</name>
  <url>maven.oschina.net</url>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <build>
    <finalName>maven1</finalName>
    

  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-compiler-plugin</artifactId>
      <configuration>
        <verbose>true</verbose>
        <compilerVersion>1.7</compilerVersion>
        <source>1.7</source>
        <target>1.7</target>
      </configuration>
    </plugin>
  </plugins>
</build>
 
  <dependencyManagement>
   <dependencies>
   <dependency>
   <groupId>junit</groupId>
   <artifactId>junit</artifactId>
   <version>3.8.1</version>
   </dependency>
   </dependencies>
  </dependencyManagement>

</project>


求大神解答!!!
stackoverflow上面的高票答案都试过了,感觉没有用
------解决思路----------------------
没有写版本号吧,怎么会找得到呢!
------解决思路----------------------
二个依赖保持第一个,并且在版本号上填上响应版本,必须用Eclipse配置自己的maven。
------解决思路----------------------
依赖没加版本号

  <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
     <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  相关解决方案