pom.xml中maven-compiler-plugin插件配置的使用
2017-03-15 19:24
621 查看
maven是个项目管理工具,如果我们不告诉它我们的代码要使用什么样的jdk版本编译的话,它就会用maven-compiler-plugin默认的jdk版本来进行处理,这样就容易出现版本不匹配的问题,以至于可能导致编译不通过的问题。例如代码中要是使用上了jdk1.7的新特性,但是maven在编译的时候使用的是jdk1.6的版本,那这一段代码是完全不可能编译成.class文件的。为了处理这一种情况的出现,在构建maven项目的时候,我习惯性第一步就是配置maven-compiler-plugin插件。
maven-compiler-plugin 指定JDK版本和编码
maven-compiler-plugin 指定JDK版本和编码
<plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <configuration> <source>1.7</source> <!-- 源代码使用的开发版本 --> <target>1.7</target> <!-- 需要生成的目标class文件的编译版本 --> <!-- 一般而言,target与source是保持一致的,但是,有时候为了让程序能在其他版本的jdk中运行(对于低版本目标jdk,源代码中需要没有使用低版本jdk中不支持的语法),会存在target不同于source的情况 --> <encoding>UTF-8</encoding> <!-- 编译是的字符编码 --> </configuration> </plugin> </plugins>
相关文章推荐
- Eclipse EE+MAVEN配置以及POM.XML的使用
- Maven中配置maven-compiler-plugin插件
- Maven: setup compiler plugin encoding without editing pom.xml
- 使用Maven插件maven-dependency-plugin拷贝所有依赖的jar和pom文件
- 一段maven pom.xml中插件的配置文件
- eclipse使用maven在pom配置Maven plugin提示错误“Plugin execution not covered by lifecycle configuration”的解决方案
- 如何在maven的pom.xml中配置jetty插件?
- Eclipse EE+MAVEN配置以及POM.XML的使用
- maven setting.xml 多仓库配置(插件依赖来自不同私服,须保证pom.xml中插件版本的唯一性)
- MyEclipse 配置maven项目pom.xml设置 上传项目到nexus私服,通过中转仓库下载插件,以及nexus的配置
- 大型Java项目中使用maven进行管理,pom.xml文件中build的配置
- Spring和Hibernate使用maven整合时pom.xml的配置
- Java maven的 pom.xml配置文件中使用全局变量配置版本号
- maven使用pom.xml 配置详解
- Maven中配置maven-compiler-plugin插件
- hibernate3-maven-plugin 使用 spring applicationContext.xml中的sessionFactory配置(2)
- maven配置私服连接(不使用mirror,在pom.xml中配置),pluginRepository作用
- Maven使用心得 -- 常用setting.xml和pom.xml配置
- maven2之m2eclipse使用手册之三第一个Simple MavenProject与Pom.xml配置说明
- hibernate3-maven-plugin 使用 spring applicationContext.xml中的sessionFactory配置(1)