背景

使用 maven 3.x 安装到本地后,创建的项目一般都是基于JDK1.5版本。而目前大多数的项目已经升级到1.6或以上,尤其是Servlet3.0 已经要求Java6或以上版本的环境,往往需要改动。

解决方案

方案一:全局设置

在${MAVEN_HOME}/conf/setting.xml中改变默认的编译版本,激活profile:

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

方案二:项目单独配置

修改pom文件中,加入以下配置:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>

maven项目修改java编译版本的方式的更多相关文章

  1. 修改Intellij Idea 创建maven项目默认Java编译版本

    在使用Intellij Idea 创建Maven项目时,默认的Java Language是1.5,虽然可以在Project Structrue中修改,但是每次pom.xml文件有变化时,工程又会重置到 ...

  2. idea修改java编译版本

    file--Settings project strustructure project strustructure

  3. 修改maven默认的JDK编译版本

    1.全局模式(settings.xml) <profiles> <profile> <id>jdk-1.8</id> <activation> ...

  4. Maven项目中,编译proto文件成Java类

    新建Maven项目 新建一个 Maven 项目: pom定义了最小的maven2元素,即:groupId,artifactId,version. groupId:项目或者组织的唯一标志,并且配置时生成 ...

  5. maven 通过 pom.xml 指定java编译版本

    <!-- 给maven项目指定编译版本 --> <plugin> <groupId>org.apache.maven.plugins</groupId> ...

  6. Maven项目执行java入口main方法

    在Maven项目中配置pom.xml文件加载maven-surefire-plugin插件来执行testng.xml,相信大家对此种用法已经非常熟悉了.但是有些场景可能需要我们去加载执行java的ma ...

  7. 详解Maven项目利用java service wrapper将Java程序生成Windows服务

    在项目的开发中,有时候需要将Java应用程序打包成Windows服务,我们就直接可以通过windows的服务来启动和关闭java程序了. 本博文将通过有两种方法实现该功能,手动创建法和Maven自动打 ...

  8. IntelliJ IDEA中Maven项目的默认JDK版本

    在IntelliJ IDEA 15中使用Maven时,IDEA将默认的编译版本.源码版本设置为jdk5.编译项目的时候出现警告:"Warning:Java: 源值1.5已过时, 将在未来所有 ...

  9. 【转】maven 项目出现 java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener

    http://blessht.iteye.com/blog/1104450 http://www.cnblogs.com/zhouyalei/archive/2011/11/30/2268606.ht ...

随机推荐

  1. [SoapUI] SoapUI JDBC REST 连接 Netezza

    How to Connect to Server 1. Apply accounts that has permission to access Netezza system for host acc ...

  2. h.SSL协议栈整体分解

    1.SSL整体框图 SSL协议是应用层次(http协议)和TCP层级的一个可选的位置,可以从下面的图中非常清楚看到该层次: 绿色的框图就是这个SSL./TLS的位置,最右面的SSL/TLS图可以进一步 ...

  3. express-generator安装时出错,最后用VPS解决

    npm install -g express-generator npm ERR! Linux 3.10.0-229.el7.x86_64npm ERR! argv "/usr/local/ ...

  4. banner秒杀

    永远显示 未开始/进行中(需要用到两个for循环,第一个我没有想到,诗詹帮我写的) function timeList(){ myTime = new Date().getTime() var ite ...

  5. PDF 补丁丁 0.4.3.1582 测试版发布:修复上一测试版的问题

    新的测试版修复了上一测试版在各功能的文件列表中无法更改单元格文本等一系列问题. 软件界面也略有调整,使新测试版更容易使用.建议下载了旧测试版的用户马上更新到新的测试版.

  6. c#网络通信框架networkcomms内核解析之十 支持优先级的自定义线程池

    NetworkComms网络通信框架序言 本例基于networkcomms2.3.1开源版本  gplv3协议 如果networkcomms是一顶皇冠,那么CommsThreadPool(自定义线程池 ...

  7. terminator终端工具

    terminator是个很好的终端程序,在Ubuntu Linux下安装如下: sudo apt-get install terminator 可在同一屏打开多个窗口:

  8. linux kernel tainted

    日志中会有一些信息: dmesg | grep -i tainted 具体代码可以通过proc看到: cat /proc/sys/kernel/tainted 数字的意义: tainted: Non- ...

  9. 保留json字符串中文的函数,代替json_encode

    // 格式化json中的汉字函数    protected function encode_json($str) {        $strs = urldecode(json_encode($thi ...

  10. DEV控件,PopupContainerEdit,PopupContainerControl,TreeList,弹出控制问题

    功能描述 PopupContainerEdit的PopupControl设置为PopupContainerControl, PopupContainerControl的里面放一个TreeList, T ...