首页 > 技术文章 > maven打包命令

huojg-21442 2017-09-04 17:43 原文

在大家用maven新建项目的时候,往往最后不会打包,下面讲解一下打包的命令

首先我们必须在pom.xmlw文件配置。日如果你想支持快捷启动。可以用

<build>
        <plugins>
            <plugin>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
            </plugin>
        </plugins>
        
        <finalName>pay</finalName>
    </build>

这是支持jetty容器的插件配置。

 

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>install</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <includeScope>provided</includeScope>
                            <outputDirectory>${jarToDir}</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.6</version>
                <executions>
                    <execution>
                        <id>copy-jar</id>
                        <phase>install</phase>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${jarToDir}</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

我们配置这样的信息,打包的时候只要在项目的目录下:

输入:mvn clean install -DskipTests命令,就可以了。

 

    <properties>
        <local.repo>${project.basedir}/../../</local.repo>
        <jarToDir>../../pay-platform/src/main/webapp/WEB-INF/lib-channels/sfjpay</jarToDir>
    </properties>

这段代码是打包,打到那里去,,那就是我们父项目中

 

推荐阅读