简体   繁体   English

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

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

I am familiar with configuring maven-compiler-plugin to use java 1.6 in pom.xml and using parent pom file.我熟悉配置 maven-compiler-plugin 以在 pom.xml 中使用 java 1.6 并使用父 pom 文件。

Is there a way to configure java compiler level to java 1.6 in the settings.xml level (so that all my maven projects will use java 1.6)?有没有办法在settings.xml级别中将java编译器级别配置为java 1.6(这样我所有的maven项目都将使用java 1.6)?

In this thread default maven compiler setting somebody told there is a way to configure it in settings.xml.在这个线程默认的 maven 编译器设置中,有人告诉有一种方法可以在 settings.xml 中配置它。 Can someone please explain how to configure?有人可以解释一下如何配置吗?

PS: Another way to specify Java compiler level: PS:另一种指定Java编译器级别的方法:

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

-Siva -湿婆

Simple answer No. In the settings file you don't configure things like this, cause it doesn't make sense and would make your builds not reproducible.简单的答案 否。在设置文件中,您不会配置这样的内容,因为它没有意义,并且会使您的构建无法重现。 The information about configuring the compiler plugin in settings.xml is rubbish. settings.xml 中关于配置编译器插件的信息是垃圾。

source/target level can be configured in settings.xml, like this:源/目标级别可以在 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