宇筱博客

  • 解决办法
  • 学无止境
  • 记录时光
  • 百宝箱
宇筱博客
点滴记忆,汇聚成海。
  1. 首页
  2. 解决办法
  3. 正文

Maven中指定Java的编译版本和源文件编码方式

2021年1月1日 405点热度 0人点赞 0条评论

使用Maven编译Java项目,默认的编译版本是1.5.

参考官网的说明-》https://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html

如果要指定Java编译版本有两种方式

1)在settings.xml中指定,例如

<profiles>
  <profile>
    <id>JDK1.7</id>
    <activation>
      <activeByDefault>true</activeByDefault>
    </activation>
    <properties>
      <maven.compiler.source>1.7</maven.compiler.source>
      <maven.compiler.target>1.7</maven.compiler.target>
      <encoding>UTF-8</encoding>
    </properties>
  </profile>
</profiles>

2)在pom.xml中指定 ,例如

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-compiler-plugin</artifactId>
      <version>${maven-compiler-plugin.version}</version>
      <configuration>
        <source>1.7</source>
        <target>1.7</target>
        <encoding>UTF-8</encoding>
      </configuration>
    </plugin>
  </plugins>
</build>

————————————————

版权声明:本文为CSDN博主「fw0124」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。

原文链接:https://blog.csdn.net/fw0124/article/details/49779121

标签: 暂无
最后更新:2021年1月1日

小渔民

这个人很懒,什么都没留下

点赞
< 上一篇
下一篇 >

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复

COPYRIGHT © 2025 宇筱博客. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang

豫ICP备15017825号-2