简体   繁体   中英

Maven compiler plugin vs maven default plugin?

Maven is a powerful build tool for Java software projects.

I was reading about Maven plugins. ( 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.

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.

If you want to change the configuration, you need to add the plugin to <plugins> and then change the configuration. 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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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