最近用Maven打包项目(本地jdk11)后放到服务器(jdk8)后,报【java.lang.UnsupportedClassVersionError】版本不一致错误。java
网上资料说是修改IntelliJ Idea的项目的源码版本、依赖版本和JavaCompiler的编译版本,试了事后发现没有解决个人问题,最后经过下面的两种解决方案解决了问题。apache
一下有两种解决方案服务器
Java 8maven
pom.xmlui
<properties> <maven.compiler.target>1.8</maven.compiler.target> <maven.compiler.source>1.8</maven.compiler.source> </properties>
Java 7插件
pom.xmlcode
<properties> <maven.compiler.target>1.7</maven.compiler.target> <maven.compiler.source>1.7</maven.compiler.source> </properties>
直接选择,配置插件xml
pom.xmlget
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.6.1</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> </plugins> </build>