首页 > 其他 > 详细

maven 学习 十 关于打包

时间:2018-06-30 23:25:40      阅读:184      评论:0      收藏:0      [点我收藏+]

clean package -Dmaven.test.skip=true -P product

这个命令干的活: 清class文件,打包构建,跳过测试,注意最后一个 -P product, 会激活项目下的pom.xml配置的<profiles>标签下id为product。

Maven提供了Profile的概念来决绝不同环境打包的问题:

<profiles>  
    <profile>  
        <id>kaifa</id>  
        <properties>  
            <db.url>192.10.2.168</db.url>  
            <db.username>dbtest</db.username>  
            <db.password>dbtest</db.password>  
        </properties>  
    </profile>  
      
    <profile>  
        <id>shengchan</id>  
        <properties>  
            <db.url>192.20.1.11</db.url>  
            <db.username>admin</db.username>  
            <db.password>comfreesecurity</db.password>  
        </properties>  
    </profile>  
</profiles>  

 常用插件:

  •   maven-jar-plugin

             打成jar时,设定manifest的参数,比如指定运行的Main class,还有依赖的jar包,加入classpath中。

              (classpath:classpath是Java运行时环境搜索类和其他资源文件(比如jar\zip等资源)的路径。可以通过JDK工具(比如javac命令、java命令)后面的-       

                                 classpath 参数设置classpath)

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <version>2.4</version>
    <configuration>
        <archive>
            <manifest>
                <addClasspath>true</addClasspath>
                <classpathPrefix>/data/lib</classpathPrefix>
                <mainClass>com.zhang.spring.App</mainClass>
            </manifest>
        </archive>
    </configuration>
</plugin>

 

  

maven 学习 十 关于打包

原文:https://www.cnblogs.com/liufei1983/p/9249006.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!