简体   繁体   English

如何使用Maven 3配置文件在IntelliJ中切换字节码目标级别

[英]How can I switch the bytecode target level in IntelliJ using Maven 3 profiles

I am using maven profiles to switch between two "setups" in Intelli J. How can I switch the bytecode target level? 我正在使用maven配置文件在Intelli J中的两个“设置”之间切换。如何切换字节码目标级别? That is: I want to change the following setting in compiler.xml 那就是:我想在compiler.xml中更改以下设置

<bytecodeTargetLevel>
  <module name="finmath-lib" target="1.6" />
</bytecodeTargetLevel>

Note: I tried to perform this via the following part in the respective Maven 3 profile 注意:我尝试通过相应的Maven 3配置文件中的以下部分执行此操作

<profile>
    <id>java-8</id>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</profile>

but this does not work! 但这不起作用!

Note: The pom.xml etc. belongs to the finmath lib project, and if you are interested, it can be found at www.finmath.net 注意:pom.xml等属于finmath lib项目,如果您有兴趣,可以在www.finmath.net找到它。

I am using IntelliJ IDEA 14.1.3 and it works with following config ... 我正在使用IntelliJ IDEA 14.1.3 ,它可以使用以下配置...

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.3</version>
    <configuration>
        <source>1.8</source>
        <target>1.8</target>
    </configuration>
</plugin>

Hope this is helpful. 希望这是有帮助的。 Thanks! 谢谢!

The problem is that you want to change it to 1.8. 问题是您要将其更改为1.8。

I've tried to switch IntelliJ's compiler version between 1.7 and 1.6 or 1.5 using Maven profile successfully . 我已经尝试使用Maven配置文件成功切换IntelliJ的编译器版本在1.7和1.6或1.5之间。

However when you want to change it to 1.8, the config will be ignored. 但是,当您要将其更改为1.8时,将忽略配置。

I don't know whether this is maven's problem or Intellj's. 我不知道这是maven的问题还是Intellj的问题。 It seems that the JDK 1.8 is not well supported now, which is understandable. 看来JDK 1.8现在得不到很好的支持,这是可以理解的。

您可以在IntelliJ中打开Maven项目工具窗口,然后从列表中选择要使用的配置文件。

在IntelliJ 13, File > Project Structure ,将Project language level设置为8.0。

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

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