maven-compiler-plugin 指定jdk的版本和编码
为了让maven的jdk编译版本一致, 使用maven-compiler-plugin插件来协助管理
建议新建maven项目后的第一步就是配置该插件
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
使用encoding参数课解决java文件的编码问题
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>default-compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
合起来就是
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<encoding>UTF8</encoding>
</configuration>
</plugin>
</plu
默认jdk版本不匹配出现的异常信息为
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project springJMS: Compilation failure: Compilation failure:
[ERROR] /home/frank/programcode/SpringJMSSample/src/main/java/huangbowen/net/jms/MessageSender.java:[6,1] error: annotations are not supported in -source 1.3
[ERROR]
[ERROR] (use -source 5 or higher to enable annotations)
[ERROR] /home/frank/programcode/SpringJMSSample/src/main/java/net/EmbedBrokerApp.java:[5,7] error: static import declarations are not supported in -source 1.3
[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
jdk1.8 的配置:
<!-- the Maven compiler plugin will compile Java source files -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.</version>
<configuration>
<encoding>UTF-</encoding>
</configuration>
</plugin>
scala 2.11.12 的配置
<!-- the Maven Scala plugin will compile Scala source files -->
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.2.</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
maven-compiler-plugin 指定jdk的版本和编码的更多相关文章
- maven中如何指定jdk的版本
问题再现: 当我们每次创建maven项目时,jdk的默认版本是1.5,而我们一般机器上安装的是1.7以上的版本,jdk版本不一样,遇到这种问题,有两种解决办法: 至于右键设置jdk版本不推荐,在此不作 ...
- [Maven] - Eclipse "maven compiler plugin" 冲突解决
刚安装最新的Maven 3.2.5,在eclipse中使用maven的Run As->Maven Install,总会提示: Failed to execute goal org.apache. ...
- maven 编译插件指定jdk版本的两种方式
第一种方式: <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration&g ...
- maven 设置pom 指定jdk版本
<profile> <id>jdk-1.8</id> <activation> <activeByDefault>true</acti ...
- 设置maven创建工程的jdk编译版本
方式一:在maven的主配置文件中指定创建工程时使用jdk1.8版本 <profile> <id>jdk-1.8</id> <activation> & ...
- maven pom.xml指定jdk
<plugins> <!-- 指定jdk --> <plugin> <groupId>org.apache.maven.plugins</grou ...
- pom指定java编译版本和编码
方法一 <properties> <!-- 文件拷贝时的编码 --> <project.build.sourceEncoding>UTF-8</project ...
- maven pom.xml设置jdk编译版本为1.8
<build> <finalName>myweb</finalName> <plugins> <!--JDK版本 --> <plugi ...
- Linux环境下TomCat使用指定JDK的版本
服务器是web服务器,在上面安装了jdk1.7和jdk1.8.及多个tomcat应用,默认/etc/profile 配置的jdk1.7,大部分tomcat应用使用的也是jdk1.7, 但目前有一个新项 ...
随机推荐
- (转)Application, Session, Cookie, Viewstate, Cache对象用法和区别
================================================================================ 1.Applicati ...
- 【repost】 原生JS执行环境与作用域深入理解
首先,我们要知道执行环境和作用域是两个完全不同的概念. 函数的每次调用都有与之紧密相关的作用域和执行环境.从根本上来说,作用域是基于函数的,而执行环境是基于对象的(例如:全局执行环境即window对象 ...
- (spfa) Highway Project (zoj 3946 )
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5718 Highway Project Time Limit: 2 Seco ...
- (BestCoder Round #64 (div.2))Array
BestCoder Round #64 (div.2) Array 问题描述 Vicky是个热爱数学的魔法师,拥有复制创造的能力. 一开始他拥有一个数列{1}.每过一天,他将他当天的数列复制一遍,放在 ...
- HDU1025贫富平衡
做01背包做到的这个LIS,常见的n2会超时,所以才有nlogn可行 先来介绍一下n2 dp[i] 表示该序列以a[i]为结尾的最长上升子序列的长度 所以第一层循环循环数组a,第二层循环循环第i个元素 ...
- js五道经典练习题--第四道qq好友列表
<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title>& ...
- 雪花算法(snowflake)delphi版
雪花算法简单描述: + 最高位是符号位,始终为0,不可用. + 41位的时间序列,精确到毫秒级,41位的长度可以使用69年.时间位还有一个很重要的作用是可以根据时间进行排序. + 10位的机器标识,1 ...
- Android-AndroidStudio加载工程方式-gradle文件夹
例如:在其他地方,其他工作人员哪里的OpenGateDemo工程是OK的, 然后Copy到李四的电脑上运行是报错,其实所有的错误都和gradle有关: 第一步,李四电脑运行OpenGateDemo工程 ...
- 程序bug导致了天大的损失,要枪毙程序猿吗?[ZZ]
来自猫扑:程序bug导致了天大的损失,要枪毙程序猿吗? 0 引言 年会上Review 源代码算什么? 法庭上 Review code 才带劲..... 2015年9月3日,随着东京最高法院驳回瑞穗证券 ...
- Windows 下环境变量设置(命令行)
0. 背景 查了一下 SETX 命令可以实现,先简单看了下帮助.以后再写一个实例. 1. SETX /? 输出内容: SetX 有三种使用方式: 语法 1: SETX [/S system [/ ...