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, 但目前有一个新项 ...
随机推荐
- 停止一个java的线程执行
找了一个停止线程运行的方法,代码如下: public class stopThread extends Thread { private volatile boolean stop = false; ...
- spark Graph 的PregelAPI 理解和使用
spark Graph 的PregelAPI 理解和使用 图本质上是一种递归的数据结构,可以使用Spark GraphX 的PregelAPI接口对图数据进行批量计算, 之前一直不怎么理解Pregel ...
- Windows核心编程:第7章 线程调度、优先级和关联性
Github https://github.com/gongluck/Windows-Core-Program.git //第7章 线程调度.优先级和关联性.cpp: 定义应用程序的入口点. // # ...
- netcore 发布 到 windows server IIS
net core 和普通net 发布没有什么不同,只需要在个别地方注意下: 1. 在visual Studio 2017 发布 2. 把发布好的文件copy到服务器上,并新建一个网站,同时要注意选择无 ...
- 定时任务 Wpf.Quartz.Demo.3
先把全部源码上传,只是一个Demo,希望大家指点一下不足之处,见本文底部. 1.设置界面 2.详情页面 好了,现在慢慢叙述里面的一些方法. 3.实现拷贝的方法: (1) public static v ...
- HashSet源码解析
此文已由作者赵计刚授权网易云社区发布. 欢迎访问网易云社区,了解更多网易技术产品运营经验. 6.1.对于HashSet需要掌握以下几点 HashSet的创建:HashSet() 往HashSet中添加 ...
- ViewPager无限滑动
2016-6-19 前言 View轮播效果在app中很常见,一想到左右滑动的效果就很容易想到使用ViewPager来实现.对于像我们常说的banner这样的效果,具备无限滑动的功能是可以用ViewPa ...
- HDU - 2604 Queuing(递推式+矩阵快速幂)
Queuing Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Su ...
- Python MySQL - 进行数据查询
#coding=utf-8 import mysql.connector import importlib import sys # reload(sys) # sys.setdefaultencod ...
- win7 配置Windows Update 失败,还原更改,无法进入系统
win7 配置Windows Update 失败,还原更改,无法进入系统 win7 系统安装好后,忘记了需要关闭自动更新,某天自动更新补丁安装失败,进入下图状态,无法进入正常系统. 解决方案一:使用+ ...