maven编译器插件2.0.2 [英] maven compiler plugin 2.0.2

查看:146
本文介绍了maven编译器插件2.0.2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请告诉我是否必须在我的POM中指定maven-compiler-plugin详细信息:

Can you please tell me is it mandatory to specify the maven-compiler-plugin details in my POM under:

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

如果是,为什么如此,我明白它的作用,但不确定为什么需要它?没有其他方法可以在maven中调用javac吗?

If yes why so, i understand what it does, but not sure why its required? Isnt there any other way to invoke the javac in maven?

推荐答案

您能告诉我是否必须指定maven-compiler-plugin详细信息?

没有。但它会使用Java 1.3或者石器时代的东西进行编译。

No. But it will use Java 1.3 or something from stone age to compile.

如果是,为什么如此,我明白它的作用,但不确定为什么需要它?

答案是'不'。但这就是原因。您确定不希望在新代码上使用Java 1.3进行编译。你想要Java 5中的所有新功能。不是吗? :)所以,你必须在已经混乱的POM中添加这些额外的行。

The answer is 'No'. But here is the reason. You sure do not want to compile using Java 1.3 on your new code. You want all the new features in Java 5. Don't you? :) So, you have to add these extra lines in your already cluttered POM.

还有没有其他方法可以调用maven中的javac?

没有。但是 mvn compile 或者任何其他命令都可以工作,即使你没有这个块。但是如果您的源代码有任何Java 5中的高级内容,但在以前的版本中没有,则编译将失败。

There isn't. But mvn compile or any other command will work even if you do not have this block. But compilation will fail if your source code has any advance stuffs that is in Java 5, but not in previous version.

编辑1

当我有JDK 5时,如何编译为1.3?

How does it compile to 1.3 when I have JDK 5?

好吧,有一个选项可以在Java编译器中设置。请参阅此处的Java编译器选项: http://docs.oracle .com / javase / 1.5.0 / docs / tooldocs / windows / javac.html

Well, there is an option to set to do so in Java compiler. See Java compiler options here: http://docs.oracle.com/javase/1.5.0/docs/tooldocs/windows/javac.html

它说你可以设置 source 等旧版本。

It says you can set source et al to older version.

这篇关于maven编译器插件2.0.2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆