1、maven配置jdk版本java
解决方案一:修改maven的配置(解压目录的conf\setting.xml文件)spring
<profile> <id>jdk1.6</id> <activation> <activeByDefault>true</activeByDefault> <jdk>1.6</jdk> </activation> <properties> <!-- want to use the Java 8 language features, Default 1.5 --> <maven.compiler.source>1.6</maven.compiler.source> <!-- want the compiled classes to be compatible with JVM 1.8, Default 1.5 --> <maven.compiler.target>1.6</maven.compiler.target> <!-- Version of the compiler to use, ex. "1.3", "1.5", if fork is set to true --> <maven.compiler.compilerVersion>1.6</maven.compiler.compilerVersion> </properties> </profile>
idea中apache
解决方案二:默认settigs.xml文件路径为:c:\users\xxx.m2\settings.xml,只要把设置好的settings.xml文件复制到该目录下windows
解决方案三:修改项目中的pom.xmlspringboot
配置1或者配置2均可以服务器
maven加载首先会加载项目而后才会加载配置文件中配置
配置1.框架
配置2.maven
<plugins> <!-- 指定maven插件编译版本 1:maven:since2.0, 默认用jdk1.3来编译,maven 3.x 貌似是默认用jdk 1.5。 2:windows默认使用GBK编码,java项目常常编码为utf8,也须要在compiler插件中指出,不然中文乱码可能会出现编译错误。 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <!-- since 2.0 --> <version>3.7.0</version> <configuration> <!-- use the Java 8 language features --> <source>1.8</source> <!-- want the compiled classes to be compatible with JVM 1.8 --> <target>1.8</target> <!-- The -encoding argument for the Java compiler. --> <encoding>UTF8</encoding> </configuration> </plugin> </plugins>
2、springboot配置jdk注意:
ide
若是springboot版本对应的不对就算再改jdk虽然编译的时候都能正常,打包运行也都正常,可是在服务器上仍是会出现奇葩的事情。编码
例如:
错误 本地机器上装的jdk8,springboot用2.1.5RELEASE版本改为jdk7的打包方式, 本地写代码用lambda表达式编译不经过,可是若是服务器上是jdk7的环境,启动就会报错。本地不管怎样都不会报错。由于是jdk8环境。
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/springframework/boot/loader/JarLauncher : Unsupported major.minor version 52.0
正确 若是用springboot用1.5.9RELEASE版本改为jdk7的打包方式,服务器上jdk7的运行环境就不会报错。能够正常启动。
总结:
因此不管用什么框架,必定要了解清楚再使用。