简体   繁体   English

Maven编译器插件vs maven默认插件?

[英]Maven compiler plugin vs maven default plugin?

Maven is a powerful build tool for Java software projects. Maven是一个用于Java软件项目的强大构建工具。

I was reading about Maven plugins. 我正在阅读Maven插件。 ( maven-compiler-plugin )_ maven-compiler-plugin )_

<build>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>
    </plugins>
</build>

For any project to run using maven, it definitely need to compile the code. 对于使用maven运行的任何项目,它肯定需要编译代码。

But i can see many sample projects online which doesn't have this plugin and still work. 但我可以在网上看到很多没有这个插件但仍然有用的示例项目。

Can anybody explain what is the difference in this plugin and by default compiling? 任何人都可以解释这个插件有什么区别,默认编译?

If you do nothing, Maven will call the maven compiler plugin which is called in the maven default lifecycle. 如果你什么也不做,Maven将调用在maven默认生命周期中调用的maven编译器插件。

If you want to change the configuration, you need to add the plugin to <plugins> and then change the configuration. 如果要更改配置,则需要将插件添加到<plugins> ,然后更改配置。 Often people do this to change the Java version (which can also be done through properties) or to fix the version of the plugin (instead of always using the latest version). 通常人们这样做是为了更改Java版本(也可以通过属性完成)或修复插件的版本(而不是总是使用最新版本)。

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

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