欢迎您光临本小站。希望您在这里可以找到自己想要的信息。。。

maven听课笔记总结(三)

Java Web water 2404℃ 0评论

maven生命周期

三大套生命周期(命令的执行过程)

  1. clean

    1. pre-clean 执行一些需要在clean之前完成的工作

    2. clean 移除所有上一次构建的文件

    3. post-clean 执行一些需要在clean之后完成的工作

  2. compile

  3. site

关键是了解compile的执行过程

其实maven的命令的执行都是在依赖插件的执行

插件是maven的核心

为了让一个插件中可以实现众多的相类似的功能,maven为插件设定了目标,一个插件中有可能有多个目标

其实生命周期中的重要的每个阶段都是由插件的一个具体目标来执行

配置插件  

http://maven.apache.org/plugins/index.html

<build>
    <plugins>
        <plugin>
            <groupId></groupId>
            <artifactId>maven-source-plugin</artifactId>
            <version>2.1.2</version>
        </plugin>
        <!--设置到某个生命周期后运行-->
        <excutions>
            <excution>
                <phase>packeage</phase>
                <goals><goal>jar-no-fork</goal></goals>
            <excution>
        </excution>
    </plugins>
    
</build>

配置在父项目中需要配置,然后子项目运行

<build>
    <pluginManagement>
        
    </pluginManagement>
</build>

使用插件时,绑定到特定的生命周期

mvn help:describe -DgroupId= -Dartifactid= -Dversion=

help:describe -Dplugin=groupId:artifactid:version

前缀就是运用什么名称快速找到插件(使用插件)

help:describe -Dplugin=compiler

<properties>
    <mysql.dirver>com.mysql.jdbc.Driver</mysql.driver>
    <mysql.url>jdbc:mysql://localhost:3306/mysql</mysql.url>
    <mysql.username></mysql.username>
</properties>

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>sql-maven-plugin</artifactId>
    <version>1.5</version>
    <dependencies>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.18</version>
        </dependency>
        <configuration>
            <driver></driver>
            <sqlCommand>
                create database IF NOT EXISTS maven_test
            </sqlCommand>
        </configuration>
        <excutions>
        </excutions>
    </dependencies>
</plugin>

数据库插件,需要加数据库驱动依赖

找插件,用插件,看帮助

转载请注明:学时网 » maven听课笔记总结(三)

喜欢 (0)or分享 (0)

您必须 登录 才能发表评论!