Unsupported major.minor version 51.0 on Junit, but not web app

核能气质少年 提交于 2019-12-13 14:30:25

问题


I'm running Junits on our app server that fail with Unsupported major.minor version 51.0. But, the web application then builds, deploys, and runs fine. I don't understand how this can happen. My maven compiler's config looks like this:

<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>

And my Junit dependency:

<dependency>
  <groupId>junit</groupId>
  <artifactId>junit</artifactId>
  <scope>test</scope>
  <version>4.10</version>
</dependency> 

Can anyone think of a reason this is failing?


回答1:


The maven-surefire-plugin is responsible for running JUnit tests. Try adding this config.

<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>


来源:https://stackoverflow.com/questions/19391314/unsupported-major-minor-version-51-0-on-junit-but-not-web-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!