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数据类型、操作符、表达式
基本与C#相同,因C#从Java学的 如操作符 对象的Equals方法,比较两个对象的内容是否相等. ==是比较是否引用同一对象.
- kepware http接口 OCaml
读取某变量的值 open Cohttp_lwt_unix open Cohttp open Lwt let uri = Uri.of_string "http://127.0.0.1:393 ...
- POJ2270&&Hdu1808 Halloween treats 2017-06-29 14:29 40人阅读 评论(0) 收藏
Halloween treats Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 8565 Accepted: 3111 ...
- java并发编程基础-ReentrantLock及LinkedBlockingQueue源码分析
ReentrantLock是一个较为常用的锁对象.在上次分析的uil开源项目中也多次被用到,下面谈谈其概念和基本使用. 概念 一个可重入的互斥锁定 Lock,它具有与使用 synchronized 相 ...
- linecache
linecache是专门支持读取大文件,而且支持行式读取的函数库. linecache 预先把文件读入缓存起来,后面如果你访问该文件的话就不再从硬盘读取.对于大文件的读取效率还不错 Help on m ...
- ASP.NET MVC 主要的四种过滤器和三种具体实现类
4种常用过滤器(IAuthrorizationFilter.IActionFilter.IResultFilter.IExceptionFilter) 和 3种具体实现类(AuthorizeAttri ...
- winform最小化后重复进load事件原因
最近编写一个工具发现的问题,窗体不论是最小化还是进入托盘,重新打开的时候都会进入控件load事件. 产生这个现象的条件是: 1.使用了用户控件,在控件中使用了load事件 2.在主窗体中,隐藏或显示任 ...
- Method not found: 'System.Data.Entity.ModelConfiguration.Configuration.XXX
使用EF flument API 修改映射数据库字段的自增长 modelBuilder.Entity<Invoice>().Property(p => p.Id).HasDatab ...
- js怎么样根据select的name取到值
先看一下ASP.NET MVC的html: 在jQuery中,可以写:
- ASP.NET MVC一次删除多笔记录 V2.0
前一段时间Insus.NET有写一篇<ASP.NET MVC一次删除多笔记录>http://www.cnblogs.com/insus/p/6241186.html 可以前往去看看. 觉得 ...