版权声明:本文为博主原创文章。未经博主同意不得转载。 https://blog.csdn.net/lizhitao/article/details/25797069

我们部署项目时常常会遇到打包部署工作(非web工程),那该怎样配置pom.xml?请看例如以下配置

1.工程文件夹

2.pom配置

2.1  注意仅仅须要配置pom中build节点就能够了。
    <build><!-- 打包工程名称  --><finalName>mafka-test</finalName><!-- 拷贝全部依赖jar到部署工程文件夹下 --><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-dependency-plugin</artifactId><executions><execution><id>copy-dependencies</id><phase>package</phase><goals><goal>copy-dependencies</goal></goals><configuration><outputDirectory>${basedir}/${build.finalName}/lib</outputDirectory><overWriteReleases>false</overWriteReleases><overWriteSnapshots>false</overWriteSnapshots><overWriteIfNewer>true</overWriteIfNewer></configuration></execution></executions></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>2.3.2</version><configuration><source>1.6</source><target>1.6</target><encoding>UTF-8</encoding></configuration></plugin><!-- 配置相关文件到部署文件夹下 --><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-resources-plugin</artifactId><version>2.5</version><executions><execution><id>copy-resources</id><phase>package</phase><goals><goal>copy-resources</goal></goals><configuration><encoding>UTF-8</encoding><outputDirectory>${basedir}/${build.finalName}</outputDirectory><resources><resource><directory>src/main/resources/</directory><includes><include>*.*</include></includes><filtering>false</filtering></resource><resource><directory>src/main/resources/config/</directory><targetPath>${basedir}/${build.finalName}/config</targetPath><includes><include>*.*</include></includes><filtering>false</filtering></resource></resources></configuration></execution></executions></plugin><!-- 打jar包时须要把配置文件给排除在外 --><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-jar-plugin</artifactId><executions><execution><phase>package</phase><goals><goal>jar</goal></goals><configuration><classifier>1.0</classifier><outputDirectory>${basedir}/${build.finalName}/lib</outputDirectory><excludes><exclude>*.xml</exclude><exclude>*.properties</exclude></excludes></configuration></execution></executions></plugin></plugins></build>

3.构建结果

/Library/Java/JavaVirtualMachines/jdk1.7.0_55.jdk/Contents/Home/bin/java -Dclassworlds.conf=/usr/local/Cellar/maven/3.2.1/libexec/bin/m2.conf -Dmaven.home=/usr/local/Cellar/maven/3.2.1/libexec -Didea.launcher.port=7543 "-Didea.launcher.bin.path=/Applications/IntelliJ IDEA 12.app/bin" -Dfile.encoding=UTF-8 -classpath "/usr/local/Cellar/maven/3.2.1/libexec/boot/plexus-classworlds-2.5.1.jar:/Applications/IntelliJ IDEA 12.app/lib/idea_rt.jar" com.intellij.rt.execution.application.AppMain org.codehaus.classworlds.Launcher --no-plugin-registry --fail-fast --strict-checksums --update-snapshots -DskipTests=true package -P nexus,nexus-snapshots
[WARNING] Command line option -npr is deprecated and will be removed in future Maven versions.
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.meituan.mafka-test:mafka-test:jar:1.0-SNAPSHOT
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: junit:junit:jar -> version 4.7 vs 4.11 @ line 149, column 21
[WARNING] The expression ${build.finalName} is deprecated. Please use ${project.build.finalName} instead.
[WARNING] The expression ${build.finalName} is deprecated. Please use ${project.build.finalName} instead.
[WARNING] The expression ${build.finalName} is deprecated. Please use ${project.build.finalName} instead.
[WARNING] The expression ${build.finalName} is deprecated. Please use ${project.build.finalName} instead.
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building mafka-test 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: http://nexus:8081/nexus/content/groups/public-snapshots/com/meituan/mtrace/mtrace/1.0.5-SNAPSHOT/maven-metadata.xml
Downloaded: http://nexus:8081/nexus/content/groups/public-snapshots/com/meituan/mtrace/mtrace/1.0.5-SNAPSHOT/maven-metadata.xml (361 B at 2.0 KB/sec)
Downloading: http://nexus:8081/nexus/content/groups/public-snapshots/com/meituan/mafka/client/mafka-client/1.0.0-SNAPSHOT/maven-metadata.xml
Downloaded: http://nexus:8081/nexus/content/groups/public-snapshots/com/meituan/mafka/client/mafka-client/1.0.0-SNAPSHOT/maven-metadata.xml (373 B at 3.5 KB/sec)
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ mafka-test ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 3 resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ mafka-test ---
[INFO] Compiling 4 source files to /Users/lizhitao/mt_wp/test_wp/kafka-test/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ mafka-test ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/lizhitao/mt_wp/test_wp/kafka-test/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ mafka-test ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ mafka-test ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:2.3.2:jar (default-jar) @ mafka-test ---
[INFO] Building jar: /Users/lizhitao/mt_wp/test_wp/kafka-test/target/mafka-test.jar
[INFO]
[INFO] --- maven-dependency-plugin:2.8:copy-dependencies (copy-dependencies) @ mafka-test ---
[INFO] Copying mafka-client-1.0.0-SNAPSHOT.jar to /Users/lizhitao/mt_wp/test_wp/kafka-test/mafka-test/lib/mafka-client-1.0.0-SNAPSHOT.jar
[INFO] Copying mtrace-1.0.5-SNAPSHOT.jar to /Users/lizhitao/mt_wp/test_wp/kafka-test/mafka-test/lib/mtrace-1.0.5-SNAPSHOT.jar
[INFO] core-3.1.1.jar already exists in destination.
[INFO] curator-framework-1.0.1.jar already exists in destination.
[INFO] oro-2.0.8.jar already exists in destination.
[INFO] commons-net-1.4.1.jar already exists in destination.
[INFO] netty-3.2.1.Final.jar already exists in destination.
[INFO] json-simple-1.1.jar already exists in destination.
[INFO] guava-10.0.1.jar already exists in destination.
[INFO] commons-logging-1.1.1.jar already exists in destination.
[INFO] commons-lang-2.6.jar already exists in destination.
[INFO] curator-client-1.0.1.jar already exists in destination.
[INFO] org.springframework.asm-3.1.1.RELEASE.jar already exists in destination.
[INFO] jsp-2.1-6.1.14.jar already exists in destination.
[INFO] scala-library-2.8.0.jar already exists in destination.
[INFO] commons-math-2.0.jar already exists in destination.
[INFO] jline-0.9.94.jar already exists in destination.
[INFO] org.springframework.beans-3.1.1.RELEASE.jar already exists in destination.
[INFO] commons-httpclient-3.1.jar already exists in destination.
[INFO] jopt-simple-4.3.jar already exists in destination.
[INFO] jackson-mapper-asl-1.5.5.jar already exists in destination.
[INFO] metrics-annotation-2.2.0.jar already exists in destination.
[INFO] xmlenc-0.52.jar already exists in destination.
[INFO] jets3t-0.7.1.jar already exists in destination.
[INFO] jetty-util-6.1.14.jar already exists in destination.
[INFO] pig-0.8.0.jar already exists in destination.
[INFO] metrics-core-2.2.0.jar already exists in destination.
[INFO] kafka_2.10-0.8.1.jar already exists in destination.
[INFO] commons-cli-1.2.jar already exists in destination.
[INFO] jackson-core-asl-1.5.5.jar already exists in destination.
[INFO] hsqldb-1.8.0.10.jar already exists in destination.
[INFO] zookeeper-3.3.3.jar already exists in destination.
[INFO] hadoop-core-0.20.2.jar already exists in destination.
[INFO] junit-4.11.jar already exists in destination.
[INFO] paranamer-2.2.jar already exists in destination.
[INFO] jsr305-1.3.9.jar already exists in destination.
[INFO] log4j-1.2.16.jar already exists in destination.
[INFO] servlet-api-2.5-6.1.14.jar already exists in destination.
[INFO] paranamer-ant-2.2.jar already exists in destination.
[INFO] kafka_2.8.0-0.8.1.jar already exists in destination.
[INFO] snappy-java-1.0.5.jar already exists in destination.
[INFO] kafka-hadoop-consumer-0.8.1.jar already exists in destination.
[INFO] org.json.simple-0.3-incubating.jar already exists in destination.
[INFO] jsp-api-2.1-6.1.14.jar already exists in destination.
[INFO] hamcrest-core-1.3.jar already exists in destination.
[INFO] jasper-compiler-5.5.12.jar already exists in destination.
[INFO] kfs-0.3.jar already exists in destination.
[INFO] jasper-runtime-5.5.12.jar already exists in destination.
[INFO] commons-codec-1.4.jar already exists in destination.
[INFO] commons-collections-3.2.1.jar already exists in destination.
[INFO] asm-3.2.jar already exists in destination.
[INFO] jetty-6.1.14.jar already exists in destination.
[INFO] zkclient-0.3.jar already exists in destination.
[INFO] qdox-1.10.1.jar already exists in destination.
[INFO] velocity-1.6.4.jar already exists in destination.
[INFO] avro-1.4.0.jar already exists in destination.
[INFO] ant-1.7.1.jar already exists in destination.
[INFO] ant-launcher-1.7.1.jar already exists in destination.
[INFO] paranamer-generator-2.2.jar already exists in destination.
[INFO] avro-1.3.2.jar already exists in destination.
[INFO] curator-test-1.0.1.jar already exists in destination.
[INFO] service-common-mtzkclient-1.6.1.jar already exists in destination.
[INFO] slf4j-api-1.6.1.jar already exists in destination.
[INFO] slf4j-log4j12-1.6.1.jar already exists in destination.
[INFO] commons-el-1.0.jar already exists in destination.
[INFO] ant-1.6.5.jar already exists in destination.
[INFO] org.springframework.core-3.1.1.RELEASE.jar already exists in destination.
[INFO] javassist-3.15.0-GA.jar already exists in destination.
[INFO] curator-recipes-1.0.1.jar already exists in destination.
[INFO]
[INFO] --- maven-resources-plugin:2.5:copy-resources (copy-resources) @ mafka-test ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 2 resources to /Users/lizhitao/mt_wp/test_wp/kafka-test/mafka-test/config
[INFO]
[INFO] --- maven-jar-plugin:2.3.2:jar (default) @ mafka-test ---
[INFO] Building jar: /Users/lizhitao/mt_wp/test_wp/kafka-test/mafka-test/lib/mafka-test-1.0.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.871 s
[INFO] Finished at: 2014-05-14T14:41:53+08:00
[INFO] Final Memory: 25M/228M
[INFO] ------------------------------------------------------------------------

例如以下图:

转载于:https://www.cnblogs.com/xfgnongmin/p/10861627.html

maven package自己主动部署包相关推荐

  1. 菜鸟教程工具(三)——Maven自己主动部署Tomcat

    书连接至背面,在博客上,他介绍了如何使用Maven该项目包,这篇文章说,关于如何使用Maven会踢war部署包Tomcat.而不是手动copy过去. 眼下比較流行的方式有两种:一种是利用Tomcat官 ...

  2. maven学习(下)利用Profile构建不同环境的部署包

    2019独角兽企业重金招聘Python工程师标准>>> 接上回继续,项目开发好以后,通常要在多个环境部署,象我们公司多达5种环境:本机环境(local).(开发小组内自测的)开发环境 ...

  3. MAVEN利用Profile构建不同环境的部署包

    通常,项目要在多个环境部署,每种环境都有各自的资源配置参数,比如:数据库连接.Redis服务器地址等等. 所以,各个环境打包出来的资源是不一样的,如果手动的修改,费时费力.我们可以利用MAVAN的pr ...

  4. java项目构建部署包

    博客分类: JAVA Java 工程在生产环境运行时,一般需要构建成一个jar,同时在运行时需要把依赖的jar添加到classpath中去,如果直接运行添加classpath很不方便,比较方便的是创建 ...

  5. Maven 手动添加第三方依赖包及编译打包和java命令行编译JAVA文件并使用jar命令打包...

    一,实例:新建了一个Maven项目,在eclipse中通过 build path –> configure path-.将依赖包添加到工程中后,eclipse不报错了.但是用Maven命令 mv ...

  6. maven打包导入本地jar包

    一 . 在项目根目录创建lib文件夹,把jar放入lib文件夹中 img 二 . 在项目中使用本地jar pom文件配置如下: <!--导入本地jar--><dependency&g ...

  7. Jenkins +maven+tomcat自动构建部署(学习笔记三十六)

    https://my.oschina.net/denglz/blog/524154 摘要: jenkins + maven + svn + tomcat 自动部署 jenkins  是做什么用的,如果 ...

  8. andriod studio 查看项目依赖_Intellij IDEA 中如何查看maven项目中所有jar包的依赖关系图...

    Maven 组件界面介绍 如上图标注 1 所示,为常用的 Maven 工具栏,其中最常用的有: 第一个按钮:Reimport All Maven Projects 表示根据 pom.xml 重新载入项 ...

  9. maven package install deploy区别

    1.maven package:打包到本项目,一般是在项目target目录下. 如果a项目依赖于b项目,打包b项目时,只会打包到b项目下target下,编译a项目时就会报错,因为找不到所依赖的b项目, ...

最新文章

  1. 愿...统一沟通...易行天下!
  2. go build -X 的妙用
  3. JAVA基础加强笔记
  4. docker 安装入门
  5. 通过反射获取方法返回的类型
  6. 动手学习_动手选择值
  7. 使用word代码域自动为图表 标号
  8. java面试问项目中遇到的问题,涨知识
  9. flutter仿ReadHub+
  10. Win32 API 概论
  11. CRM客户关系管理能给企业带来什么样的效果
  12. 计算机机超级用户,电脑超级密码的设置方法
  13. 神经网络学习9--过拟合 (Overfitting)的解决办法
  14. 《CSS禅意花园》明日上市
  15. 12个最佳的响应式网页设计教程,轻松带你入门!
  16. 公司该如何创建适合自己的区块链产品、联盟链、私链
  17. Openwrt-Chaos_Calmer搭建编译环境问题处理
  18. 芯片制造之掩模领域中的术语
  19. Android 音乐播放器的开发教程(三) 小卷毛播放器的主界面开发 ---- 小达
  20. input标签的类型有哪些

热门文章

  1. go语言中fallthrough与break的使用
  2. SuperMap导航条控件设置
  3. java钩子函数(hook)以spring源码为例
  4. 原子操作的实现原理(锁和循环CAS)
  5. 一文搞定C语言本地变量和全局变量
  6. 1041 Be Unique
  7. Fabric学习笔记-PBFT算法
  8. JZOJ 4726. 【NOIP2016提高A组模拟8.22】种花
  9. 为什么在反向传播中感知器初始值不能为0_深度学习理论分享之——单层感知器简述...
  10. python向量机使用方法_Python中支持向量机SVM的使用方法详解