利用Maven安装jar包,提取jar包

2015-03-16  本文已影响1106人  v_wee

安装jar包

1.pom如下配置

    <properties>
        <mysql.driver.version>5.1.13</mysql.driver.version>      
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>${mysql.driver.version}</version>
            <scope>runtime</scope>
        </dependency>   
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>         
    </dependencies>

2.执行mvn clean install -Dmaven.test.skip=true
安装依赖包至M2仓库
-Dmaven.test.skip=true,不执行测试用例,也不编译测试用例类。

拷贝依赖包至指定位置

1.pom.xml如下配置

    <build> 
        <plugins> 
            <plugin> 
                <artifactId>maven-dependency-plugin</artifactId> 
                <configuration> 
                    <outputDirectory>${project.build.directory}/lib</outputDirectory> 
                    <excludeTransitive>false</excludeTransitive> 
                    <stripVersion>true</stripVersion> 
                </configuration> 
            </plugin> 
        </plugins> 
    </build> 

2.执行mvn dependency:copy-dependencies
所有依赖的jar将提取到lib目录

上一篇下一篇

猜你喜欢

热点阅读