繁体   English   中英

如何在 maven settings.xml 中配置编译器级别(1.6)?

[英]How to configure compiler level (1.6) in maven settings.xml?

我熟悉配置 maven-compiler-plugin 以在 pom.xml 中使用 java 1.6 并使用父 pom 文件。

有没有办法在settings.xml级别中将java编译器级别配置为java 1.6(这样我所有的maven项目都将使用java 1.6)?

在这个线程默认的 maven 编译器设置中,有人告诉有一种方法可以在 settings.xml 中配置它。 有人可以解释一下如何配置吗?

PS:另一种指定Java编译器级别的方法:

<properties>
       <maven.compiler.source>1.6</maven.compiler.source>
       <maven.compiler.target>1.6</maven.compiler.target>
</properties>

-湿婆

简单的答案 否。在设置文件中,您不会配置这样的内容,因为它没有意义,并且会使您的构建无法重现。 settings.xml 中关于配置编译器插件的信息是垃圾。

源/目标级别可以在 settings.xml 中配置,如下所示:

<profiles>
    <profile>
      <id>jdk-1.6</id>
      <activation>
          // can be replaced with other conditions
          <jdk>1.6</jdk>
      </activation>
      <properties>
          <maven.compiler.source>1.6</maven.compiler.source>
          <maven.compiler.target>1.6</maven.compiler.target>
          <maven.compiler.compilerVersion>1.6</maven.compiler.compilerVersion>
      </properties>
    </profile>
</profiles>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM