原文: https://stackoverflow.com/questions/29258141/maven-compilation-error-use-source-7-or-higher-to-enable-diamond-operator/31734791#31734791

--------------------------------------------------------------------------------------------------------

WHY IT HAPPENS

The problem arises because

[...] 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.

Maven Compiler Plugin Introduction

That's why changing the JDK has no effect on the source level. So you have a couple of way to tell Maven what source level to use.

SOLUTIONS

  • Configure the Maven compiler plugin in the pom.xml
<build>

<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
...
  • OR Set these properties (always in the pom)
<properties>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>

JDK VERSION TO USE?

If you set a target 1.7 like in this example be sure that the mvn command is actually launched with a jdk7 (or higher)

LANGUAGE LEVEL ON THE IDE

Usually IDEs use maven pom.xml file as a source of project configuration. Changing the compiler settings in the IDE not always has effect on the maven build. That's why, the best way to keep a project always manageable with maven (and interoperable with other IDEs) is edit the pom.xml files and instruct the IDE to sync with maven.

maven 的编译插件的配置的更多相关文章

  1. Maven中常用插件的配置

    在Maven项目的pom.xml文件中配置插件信息,使用<build></build>标签 1.配置JDK版本插件和Tomcat版本插件 <build> <! ...

  2. Eclipse Class Decompiler——Java反编译插件手工配置方法

    最近在eclipse上配置了java反编译插件,但是不好用,原因是我的eclipse之前有手动配置过一些类似的java反编译插件,当我将原来的插件完全卸载后重新配置才正常配置上去,自动配置java反编 ...

  3. maven编译插件版本配置案例

    <!-- Build Settings 构建设置 --> <build> <finalName>${project.artifactId}</finalNam ...

  4. 到底如何配置 maven 编译插件的 JDK 版本

    千言万语不及官方文档,详情请阅读 compiler:compile 文档 配置 maven 编译插件的 JDK 版本 maven 编译插件(maven-compiler-plugin)有默认编译 JD ...

  5. maven中jetty插件配置

    maven中jetty插件的配置,可用于项目在内置jetty服务器中的部署. <plugin> <groupId>org.mortbay.jetty</groupId&g ...

  6. Maven 添加 Tomcat 插件

    若想在 Maven 中使用 Tomcat 服务器,需要在 pom.xml 文件中的 <build></build> 标签中添加以下代码 <!-- Maven项目编译插件 ...

  7. maven常用插件pom配置

    一.问题描述: 部署一个maven打包项目时,jar包,依赖lib包全部手动上传至服务器,然后用maven部署报错:Exception in thread "main" java. ...

  8. Maven常用插件简单配置

    好久不见,甚是想念.一日不见,如隔三秋. 从春节到现在已经很久没有回归博客园了,今天回来温习一下maven常用的一些插件的配置,学东西一个很简单的诀窍就是重复重复再重复,这样一定能把知识掌握的很牢靠. ...

  9. 1.Maven+SpringMVC+Eclipse软件安装配置,Maven报插件错误,Eclipse总是卡死的解决办法,导入一个maven工程后 一直显示importing maven project

     使用Maven+SpringMVC+Eclipse软件安装配置过程中的问题: 1.Eclipse总是卡死的解决办法: 一:内存不足所以会卡死,配置一下eclipse.ini修改这几个值就好了-X ...

随机推荐

  1. python_对字符串操作.join() 效率 比 + 效率高

    将列表中的字符拼接成字符串时,有两种方式 方式1:使用join()方法,将列表转为字符串 方式2:使用+运算符,循环遍历 import time str1 = ['a','b','c','d','e' ...

  2. iview table icon dorpdown html页面级别vue组件 #vuez#

    iview table icon dorpdown html页面级别vue组件 <!DOCTYPE html> <html> <head> <meta cha ...

  3. New Arrival MB SD Connect Compact 5 (MB SD C4) Star Diagnosis

    MB SD Connect Compact 5 has same function as SD C4 but with new design, support both cars and trucks ...

  4. 主成分分析、因子分析、ICA(未完成)

    并且SVD分解也适用于一般的矩阵. 主成分分析可以简单的总结成一句话:数据的压缩和解释.常被用来寻找判断某种事物或现象的综合指标,并且给综合指标所包含的信息以适当的解释.在实际的应用过程中,主成分分析 ...

  5. spring中bean的配置详解--定义parent

    在工作中碰到了好多的配置文件,具体来说是spring 中bean配置的parent的配置,搞的我一头雾水,仔细看一下spring中有关bean的配置,剖析一下,具体什么含义! 一.Spring IoC ...

  6. nginx发布web网站

    修改/conf/nginx.conf配置文件 server { listen *:; # Listen server_name ""; # Don't worry if " ...

  7. spring注解开发-声明式事务(源码)

    1. 环境搭建与测试 1)导入相关依赖 数据源.数据库驱动.Spring-jdbc模块 <dependency> <groupId>org.springframework< ...

  8. PyQt5-Python3-PyCharm 配置

    File->Tools->External Tools->add 配置ui文件转换工具 Name: PyUIC Program: D:\develop\python\Mac\venv ...

  9. bootstrap3之栅格系统

    原理 栅格系统的核心就是媒体查询.指定的尺寸都是百分比,也就是流式布局. 查看bootstrap中的源码可以发现,对样式的定义次序全都是依次 xs.sm.md.lg,如: // grid-framew ...

  10. Python旅途——文件操作

    Python--文件操作 1.理解文件操作 可能有的时候有人会在想为什么要对文件进行操作,无论对于文件还是网络之间的交互,我们都是建立在数据之上的,如果我们没有数据,那么很多的事情也就不能够成立,比如 ...