4

我在我们的应用服务器上运行 Junits,但由于Unsupported major.minor version 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> 

谁能想到这失败的原因?

4

1 回答 1

6

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>
于 2013-10-16T16:56:27.670 回答