1.问题: 为什么Maven Update Project JDK变回1.5

解释:官方文档

The Compiler Plugin is used to compile the sources of your project. Since 3.0, the default compiler is javax.tools.JavaCompiler (if you are using java 1.6) and is used to compile Java sources. If you want to force the plugin using javac, you must configure the plugin option forceJavacCompilerUse.

Also note that at present the default source setting is 1.5 and the default target setting is 1.5, independently of the JDK you run Maven with. If you want to change these defaults, you should set source and target as described in Setting the -source and -target of the Java Compiler.

译:编译器插件用来编译项目的源文件.从3.0版本开始, 用来编译Java源文件的默认编译器是javax.tools.JavaCompiler (如果你是用的是java 1.6) . 如果你想强制性的让插件使用javac,你必须配置插件选项 forceJavacCompilerUse. 同时需要注意的是目前source选项和target 选项的默认设置都是1.5, 与运行Maven时的JDK版本无关. 如果你想要改变这些默认设置, 可以参考 Setting the -source and -target of the Java Compiler中的描述来设置 source 和target 选项.

解决办法:1.全局解决方式(针对所有项目),2.局部解决方式(只针对当前项目)

解决1:设置全局的jdk,在setting.xml文件中的profiles元素添加profile配置

    <profile>
<id>jdk1.8</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.8</jdk>
</activation>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
</properties>
</profile>

Jdk版本信息根据自己的情况修改。

如果找不到setting.xml文件,请查看:http://www.cnblogs.com/jingmoxukong/p/6050172.html?utm_source=gold_browser_extension

解决2:在项目的pom,xml文件中添加如下build元素

    <build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>

问题解决

2.问题:eclipse 中 右击项目 执行 Run As--> Maven install

输出信息:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile (default-testCompile) on project eboot: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

原因:maven其实是有一个默认的仓库.m2仓库和默认的settings.xml配置文件,我们在这个默认的settings.xml文件中也添加了一个JAVA8_HOME的变量后,编译就通过了,这就说明,maven编译的时候找的不是我在idea中配置的我自定义的settings.xml,而是先找的它默认的那个。因为里面没有,所以之前找不到JAVA8_HOME,导致编译失败、

解决办法:在setting.xml文件中的profiles元素添加profile配置,

    <profile>
<id>custom-compiler</id>
<properties>
<JAVA8_HOME>D:\Program Files\Java\jdk1.8.0_101</JAVA8_HOME>
</properties>
</profile>

需要激活上面的配置,在profiles配置外添加activeProfiles元素

  <activeProfiles>
<activeProfile>custom-compiler</activeProfile>
</activeProfiles>

JAVA_HOME路径根据自己的情况配置

问题解决

参考文档:http://blog.csdn.net/kqygww/article/details/12922135

http://blog.csdn.net/u011734144/article/details/51894942

关于eclipse创建Maven项目创建的问题的更多相关文章

  1. 分模块创建maven项目(一)

    maven是一个项目构建和管理的工具. 我们可以通过maven仓库可以实现管理构建(主要是JAR还包括:WAR,ZIP,POM等等). 我们可以通过maven插件可以实现编译源代.产生Javadoc文 ...

  2. m2eclipse简单使用,创建Maven项目 ,运行mvn命令(转)

    前面介绍了如何安装m2eclipse,现在,我们使用m2ecilpse导入Hello World项目. 选择菜单项File,然后选择Import,我们会看到一个Import对话框,在该对话框中选择Ge ...

  3. (八)Eclipse创建Maven项目运行mvn命令

    1.Eclipse创建Maven项目 使用Eclipse创建一个Maven项目非常的简单,选择菜单项File>New>Other(也可以在项目结构空白处右击鼠标键),在弹出的对话框中选择M ...

  4. 【项目管理和构建】十分钟教程,eclipse配置maven + 创建maven项目(三)

    [项目管理和构建]十分钟教程,eclipse配置maven + 创建maven项目(三) 上篇博文中我们介绍了maven下载.安装和配置(二),这篇博文我们配置一下eclipse,将它和maven结合 ...

  5. Maven安装和配置,eclipse创建Maven项目

    提示:使用Maven需要先安装jdk. 下载安装Maven 一.下载最新版的Maven,下载地址:http://maven.apache.org/download.cgi 二.将Maven下载到E:\ ...

  6. 用eclipse创建maven项目

    Maven是基于项目对象模型(POM),也可以进行模块化开发.并且是个强大的管理工具.本经验用eclipse来创建maven项目 步骤: 1.下载并正确安装eclipse 2.在eclipse上成功安 ...

  7. eclipse配置maven + 创建maven项目

        登录|注册     努力+坚持,而且还很年轻   目录(?)[+] 在现实的企业中,以低成本.高效率.高质量的完成项目,不仅仅需要技术大牛,企业更加需要管理大牛,管理者只懂技术是远远不够的.当 ...

  8. eclipse 创建maven 项目 动态web工程报错

    Eclipse 创建maven 项目 动态web工程 注:Eclipse版本为(Version: Mars.1 Release (4.5.1))maven版本为(apache-maven-3.3.9) ...

  9. eclipse配置maven + 创建maven项目(三)

    上篇博文中我们介绍了maven下载.安装和配置(二),这篇博文我们配置一下eclipse,将它和maven结合,并我们创建一个maven的项目. 准备工作 在eclipse配置maven之前需要我们做 ...

随机推荐

  1. Echarts自适应浏览器大小

    var myChart = echarts.init(document.getElementById('sitesChar')); var option = { title : { text: 'No ...

  2. Count on the path

    Count on the path Time Limit: 5000/2500 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Othe ...

  3. MySQL 常用基础命令

    一.启动与关闭 1.1 Linux下启动mysql 的命令: a. rpm包安装:service mysqld start b. 源码包安装:/usr/local/mysql/bin/mysqld_s ...

  4. linux系统tomcat项目部署和tomcat访问日志

    一.只用ip地址访问 先把端口号改成80,然后用 <Host name="localhost"  appBase="webapps"    137     ...

  5. display:block;inline;inline-block大总结

    总体概念 block和inline这两个概念是简略的说法,完整确切的说应该是 block-level elements (块级元素) 和 inline elements (内联元素).block元素通 ...

  6. java 基础的几种算法

    1:冒泡排序:2个之间进行循环筛选   public void sort(int[] a) { int temp = 0; for (int i = a.length - 1; i > 0; i ...

  7. Chapter 1 First Sight——10

    Instead, I was ivory-skinned, without even the excuse of blue eyes or red hair, despite the constant ...

  8. ArrayList遍历的同时删除--- 删除还是用迭代器的比较好,其它的都会有问题.

    http://javag.iteye.com/blog/403097 ArrayList遍历的同时删除-- 删除还是用迭代器的比较好,其它的都会有问题.     博客分类: 随笔 Javathread ...

  9. shortcut to open a linux terminal

    1) alt+ f2 2) input "gnome-terminal" 3) press "enter"

  10. zf-关于触摸屏子系统(查询机)的页面

    这个页面 一般是 touch/index.jsp 这个要记下来. -- 今天有个任务 是把查询机的UI页面给换掉