我在我们的应用服务器上运行Junits,但失败了,但出现不支持的major.minor 51.0 版本。但是,Web应用程序随后可以构建,部署和运行正常。我不知道这怎么会发生。我的Maven编译器的配置如下所示:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-compiler-plugin</artifactId>
  <version>2.3.2</version>
  <configuration>
    <verbose>true</verbose>
    <fork>true</fork>
    <source>1.7</source>
    <target>1.7</target>
    <executable>${JAVA_1_7_HOME}/bin/javac</executable>
    <encoding>ISO-8859-1</encoding>
    <verbose>true</verbose>
  </configuration>
</plugin>

还有我的Junit依赖项:
<dependency>
  <groupId>junit</groupId>
  <artifactId>junit</artifactId>
  <scope>test</scope>
  <version>4.10</version>
</dependency>

谁能想到失败的原因吗?

最佳答案

maven-surefire-plugin负责运行JUnit测试。尝试添加此配置。

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <version>2.16</version>
  <configuration>
    <jvm>${JAVA_1_7_HOME}/bin/javac</jvm>
  </configuration>
</plugin>

09-10 01:04
查看更多