取maven copy部分

mvn deploy:deploy-file -DgroupId=com.mycompany -DartifactId=my-project -Dversion=1.0.0 -Dpackaging=jar -Dfile=myproject-name.jar -Durl=http://localhost:8081/nexus/content/repositories/release/ -DrepositoryId=releasemvn install:install-file -Dfile=/home.jar -DgroupId=xx -DartifactId=xx -Dversion=1.0 -Dpackaging=jar

[html] view plain copy

print?

  1. 这句话可以将下载的jar包,放到本地仓库中

[html] view plain copy

print?

  1. maven实际应用
  2. lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  4. <modelVersion>4.0.0</modelVersion>
  5. <groupId>com.xuanwu</groupId>
  6. <artifactId>sxt_mtoserver</artifactId>
  7. <version>1.0-SNAPSHOT</version>
  8. <packaging>jar</packaging>
  9. <name>sxt_mtoserver</name>
  10. <url>http://maven.apache.org</url>
  11. <properties>
  12. <!-- 自定义变量 -->
  13. <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  14. <project.deploy>deploy</project.deploy>
  15. </properties>
  16. <build>
  17. <plugins>
  18. <!-- maven编译插件,指定编译jdk版本
  19. 如果编译目标版本是1.6,然后在1.5虚拟机上运行错误提示Bad version number in .class file。所以,如果希望在1.5编译时就发现错误,就要用1.5的编译器-->
  20. <plugin>
  21. <groupId>org.apache.maven.plugins</groupId>
  22. <artifactId>maven-compiler-plugin</artifactId>
  23. <version>2.3.2</version>
  24. <configuration>
  25. <source>1.5</source>
  26. <target>1.5</target>
  27. </configuration>
  28. </plugin>
  29. <!-- maven打包插件,可执行jar包配置 -->
  30. <!--
  31. <plugin>
  32. <groupId>org.apache.maven.plugins</groupId>
  33. <artifactId>maven-shade-plugin</artifactId>
  34. <version>1.4</version>
  35. <executions>
  36. <execution>
  37. <phase>package</phase>
  38. <goals>
  39. <goal>shade</goal>
  40. </goals>
  41. <configuration>
  42. <transformers>
  43. <transformer
  44. implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
  45. <mainClass>com.xuanwu.mtoserver.App</mainClass>
  46. </transformer>
  47. </transformers>
  48. </configuration>
  49. </execution>
  50. </executions>
  51. </plugin>
  52. -->
  53. <!-- maven源文件插件 -->
  54. <plugin>
  55. <groupId>org.apache.maven.plugins</groupId>
  56. <artifactId>maven-resources-plugin</artifactId>
  57. <version>2.5</version>
  58. <executions>
  59. <execution>
  60. <id>copy-resources</id>
  61. <phase>package</phase>
  62. <goals>
  63. <goal>copy-resources</goal>
  64. </goals>
  65. <configuration>
  66. <encoding>UTF-8</encoding>
  67. <outputDirectory>${project.build.directory}/${project.deploy}/conf
  68. </outputDirectory>
  69. <resources>
  70. <resource>
  71. <directory>src/main/resources/</directory>
  72. <includes>
  73. <include>*.xml</include>
  74. <include>*.properties</include>
  75. <include>*.conf</include>
  76. </includes>
  77. </resource>
  78. </resources>
  79. </configuration>
  80. </execution>
  81. <execution>
  82. <id>copy-sh</id>
  83. <phase>package</phase>
  84. <goals>
  85. <goal>copy-resources</goal>
  86. </goals>
  87. <configuration>
  88. <encoding>UTF-8</encoding>
  89. <outputDirectory>${project.build.directory}/${project.deploy}/
  90. </outputDirectory>
  91. <resources>
  92. <resource>
  93. <directory>src/main/resources/</directory>
  94. <includes>
  95. <include>*.sh</include>
  96. <include>*.pl</include>
  97. <include>*.bat</include>
  98. </includes>
  99. </resource>
  100. </resources>
  101. </configuration>
  102. </execution>
  103. </executions>
  104. </plugin>
  105. <!-- maven打jar包插件,打包后不包含pom.xml文件 -->
  106. <plugin>
  107. <groupId>org.apache.maven.plugins</groupId>
  108. <artifactId>maven-jar-plugin</artifactId>
  109. <version>2.3.2</version>
  110. <configuration>
  111. <archive>
  112. <!-- 打包后不包括pom的描述文件 -->
  113. <addMavenDescriptor>false</addMavenDescriptor>
  114. <!-- Maven在生成jar时,并不知道这个jar是lib还是app,所以使用以下这个插件告之MAVEN这个jar为app,指定main类 -->
  115. <manifest>
  116. <mainClass>com.xuanwu.mtoserver.util.Test</mainClass>
  117. </manifest>
  118. </archive>
  119. </configuration>
  120. <executions>
  121. <execution>
  122. <id>jarexclude</id>
  123. <phase>package</phase>
  124. <goals>
  125. <goal>jar</goal>
  126. </goals>
  127. <configuration>
  128. <outputDirectory>${project.build.directory}/${project.deploy}/lib</outputDirectory>
  129. <excludes>
  130. <exclude>*.xml</exclude>
  131. <exclude>*.pl</exclude>
  132. <exclude>*.sql</exclude>
  133. <exclude>*.properties</exclude>
  134. <exclude>*.bat</exclude>
  135. <exclude>*.conf</exclude>
  136. <exclude>*.sh</exclude>
  137. <exclude>*.doc</exclude>
  138. </excludes>
  139. </configuration>
  140. </execution>
  141. </executions>
  142. </plugin>
  143. <!-- maven打war包插件,打包后不包含pom.xml文件 -->
  144. <!--
  145. <plugin>
  146. <groupId>org.apache.maven.plugins</groupId>
  147. <artifactId>maven-war-plugin</artifactId>
  148. <version>2.1.1</version>
  149. <configuration>
  150. <archive>
  151. <addMavenDescriptor>false</addMavenDescriptor>
  152. </archive>
  153. </configuration>
  154. </plugin>
  155. -->
  156. <!-- 想要把工程的所有依赖的jar都一起打包 -->
  157. <!--
  158. <plugin>
  159. <groupId>org.apache.maven.plugins</groupId>
  160. <artifactId>maven-assembly-plugin</artifactId>
  161. <version>2.2.1</version>
  162. <configuration>
  163. <descriptorRefs>
  164. <descriptorRef>jar-with-dependencies</descriptorRef>
  165. </descriptorRefs>
  166. </configuration>
  167. </plugin>
  168. -->
  169. <!-- 将项目所有包放到一个指定目录 -->
  170. <plugin>
  171. <groupId>org.apache.maven.plugins</groupId>
  172. <artifactId>maven-dependency-plugin</artifactId>
  173. <version>2.3</version>
  174. <executions>
  175. <execution>
  176. <id>copy-dependencies</id>
  177. <phase>package</phase>
  178. <goals>
  179. <goal>copy-dependencies</goal>
  180. </goals>
  181. <configuration>
  182. <outputDirectory>${project.build.directory}/${project.deploy}/lib</outputDirectory>
  183. <overWriteReleases>false</overWriteReleases>
  184. <overWriteSnapshots>false</overWriteSnapshots>
  185. <overWriteIfNewer>true</overWriteIfNewer>
  186. </configuration>
  187. </execution>
  188. </executions>
  189. </plugin>
  190. </plugins>
  191. </build>
  192. <dependencies>
  193. <dependency>
  194. <groupId>junit</groupId>
  195. <artifactId>junit</artifactId>
  196. <version>3.8.1</version>
  197. <scope>test</scope>
  198. </dependency>
  199. <dependency>
  200. <groupId>axis</groupId>
  201. <artifactId>axis</artifactId>
  202. <version>1.4</version>
  203. <type>jar</type>
  204. <scope>compile</scope>
  205. </dependency>
  206. <dependency>
  207. <groupId>axis</groupId>
  208. <artifactId>axis-jaxrpc</artifactId>
  209. <version>1.4</version>
  210. <type>jar</type>
  211. <scope>compile</scope>
  212. </dependency>
  213. <dependency>
  214. <groupId>commons-discovery</groupId>
  215. <artifactId>commons-discovery</artifactId>
  216. <version>20040218.194635</version>
  217. <type>jar</type>
  218. <scope>compile</scope>
  219. </dependency>
  220. <dependency>
  221. <groupId>commons-logging</groupId>
  222. <artifactId>commons-logging</artifactId>
  223. <version>1.1.1</version>
  224. <type>jar</type>
  225. <scope>compile</scope>
  226. </dependency>
  227. <dependency>
  228. <groupId>axis</groupId>
  229. <artifactId>axis-saaj</artifactId>
  230. <version>1.4</version>
  231. <type>jar</type>
  232. <scope>compile</scope>
  233. </dependency>
  234. <dependency>
  235. <groupId>axis</groupId>
  236. <artifactId>axis-wsdl4j</artifactId>
  237. <version>1.5.1</version>
  238. <type>jar</type>
  239. <scope>compile</scope>
  240. </dependency>
  241. </dependencies>
  242. lt;/project>

原地址:http://www.blogjava.NET/toby/archive/2011/11/01/362460.html

[html] view plain copy

print?

  1. maven工程编译并生成可执行JAR包命令
  2. 2012-02-03 09:54 提问者: 储流香 |浏览次数:3230次
  3. 在JAVA持续集成构建中,需要从SVN check out的代码编译并打成可执行JAR包,高手告诉我maven命令如何?
  4. 我用mvn compile package或mvn jar:jar都能打成jar包,但不能执行
  5. 问题补充:
  6. 利用HUDSON+MAVEN编译打包java maven工程,打包成可执行的JAR包。在HUDSON中需要填写maven命令。我想知道的是打可执行jar包的maven命令。
  7. 我的pom.xml中添加了:
  8. <plugin><artifactId>maven-assembly-plugin</artifactId><configuration><descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef></descriptorRefs><archive> <manifest>mainClass>com.ImageViewer.dao.ImageViewer</mainClass></manifest>               </archive></configuration></plugin>
  9. 目前的mvn命令是:clean assembly:assembly
  10. 但是build时报错:mavenExecutionResult exceptions not empty
  11. org.apache.maven.InternalErrorException: Internal error: ava.lang.NullPointerException
  12. 换成jar:jar打成的jar包不能执行。
  13. 我来帮他解答
  14. 满意回答
  15. 2012-02-03 15:28
  16. <plugins>
  17. <plugin>
  18. <groupId>org.apache.maven.plugins</groupId>
  19. <artifactId>maven-compiler-plugin</artifactId>
  20. <version>2.3.2</version>
  21. <configuration>
  22. <source>1.6</source>
  23. <target>1.6</target>
  24. <encoding>UTF-8</encoding>
  25. </configuration>
  26. </plugin>
  27. <plugin>
  28. <groupId>org.apache.maven.plugins</groupId>
  29. <artifactId>maven-jar-plugin</artifactId>
  30. <configuration>
  31. <archive>
  32. <manifest>
  33. <addClasspath>true</addClasspath>
  34. <classpathPrefix>lib/</classpathPrefix>
  35. <mainClass>com.abc.ABCTest</mainClass>    -->入口类名
  36. </manifest>
  37. </archive>
  38. </configuration>
  39. </plugin>
  40. <plugin>
  41. <groupId>org.apache.maven.plugins</groupId>
  42. <artifactId>maven-dependency-plugin</artifactId>
  43. <executions>
  44. <execution>
  45. <id>copy</id>
  46. <phase>install</phase>
  47. <goals>
  48. <goal>copy-dependencies</goal>
  49. </goals>
  50. <configuration>
  51. <outputDirectory>${project.build.directory}/lib</outputDirectory>  -->拷贝所以依赖存放位置
  52. </configuration>
  53. </execution>
  54. </executions>
  55. </plugin>
  56. </plugins>
  57. 然后再用mvn clean install 装配一下,打出的jar包就可以运行

maven deploy到nexus报错:Return code is: 401, ReasonPhrase:Unauthorized

分类: maven2012-11-12 13:54 557人阅读 评论(2)收藏举报

提交到nexus时候报错:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project *: Failed to deploy artifacts: Could not transfer artifact *:jar:1.0 from/to releases (http://10.1.81.199:8081/nexus/content/repositories/releases/): Failed to transfer file:http://10.1.81.199:8081/nexus/content/repositories/releases/com/cs2c/security-management-client* /1.0/*-1.0.jar. Return code is: 401, ReasonPhrase:Unauthorized.

原来是没有配置认证。

maven目录conf的setting.xml里,

  1. <server>
  2. <id>releases</id>
  3. <username>admin</username>
  4. <password>admin123</password>
  5. </server>
  6. <server>
  7. <id>snapshots</id>
  8. <username>admin</username>
  9. <password>admin123</password>
  10. </server>
  11. </servers>

用户名和密码都是nexus的。再次deploy即可。

注意这里的id要和pom.xml里远程deploy的地址对应一致,我的pom.xml里配置:

  1. <!-- 配置远程发布到私服,mvn deploy -->
  2. <distributionManagement>
  3. <repository>
  4. <id>releases</id>
  5. <name>Nexus Release Repository</name>
  6. <url>http://10.1.81.199:8081/nexus/content/repositories/releases/</url>
  7. </repository>
  8. <snapshotRepository>
  9. <id>snapshots</id>
  10. <name>Nexus Snapshot Repository</name>
  11. <url>http://10.1.81.199:8081/nexus/content/repositories/snapshots/</url>
  12. </snapshotRepository>
  13. </distributionManagement>

如果这里不配置,会报错:报错:Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.5:deploy (default-deploy) on project git-demo: Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter

时间: 2024-11-08 15:49:29

取maven copy部分的相关文章

maven copy 依赖jar包

<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <executions> <execution> <id>copy-dependencies</id> <phase>prepare-package</phase> <

Java + Selenium + TestNG + Maven 框架实现Web Automation

环境准备: 1. Java: Install Java jdk: Version: java 1.8 or aboveConfigure Java Environment Variables:Add JAVA_HOMEAdd CLASSPATHAdd to Path Verify Java was configured: Input javac in CMD can get output successfully. 2. Eclipse https://www.eclipse.org/ Unzi

开发运维日常坑 总结 51-100

51.json 好多种 JsonArray fromObject = JSONArray.fromObject(list<obj>); String string = fromObject.toString(); Gson gson = new Gson(); String json = gson.toJson(list<obj>); 52.调用API //参数url化 String city = java.net.URLEncoder.encode("北京",

原生拖拽,拖放事件(drag and drop)

原生拖拽,拖放事件(drag and drop) 拖拽,拖放事件可以通过拖拽实现数据传递,达到良好的交互效果,如:从操作系统拖拽文件实现文件选择,拖拽实现元素布局的修改. drag and drop事件流程 一个完整的drag and drop流程通常包含以下几个步骤: 设置可拖拽目标.设置属性draggable="true"实现元素的可拖拽. 监听dragstart设置拖拽数据 为拖拽操作设置反馈图标(可选) 设置允许的拖放效果,如copy,move,link 设置拖放目标,默认情况

项目自动化建构工具gradle 入门4——javaWeb在浏览器中显示helloWorld

在java应用中,其实做的最多的还是java web应用.所以现在我们做的就是用gradle构建一个简单的web项目,简单点,直接上代码吧. 1.进入目录D:\work\gradle\web,新建文件build.gradle,键入内容: 1 apply plugin: 'war' // 引入war插件, 2 3 repositories { // 从哪里找jar包 4 flatDir { 5 // 先看下build.gradle文件所在目录下的 libs目录中有没有 6 dirs 'libs'

Docker学习总结

转自:http://www.cnblogs.com/I-will-be-different/p/4353597.html Docker个人学习总结 最近一段时间学习了下Docker,关于Docker的安装,运用什么的在这里我不会过多的说明,我只说我对于Docker的一些理解,附加我用于记录的少量代码. 刚开始学习Docker的时候,找资料在网上看到最多的是Docker的好处.比如: 1.Docker 容器的启动可以在秒级实现,这相比传统的虚拟机方式要快得多 2.Docker 对系统资源的利用率很

工作笔记5.JAVA文本框验证码

本文主要内容为:利用JAVA文本框制作验证码. 设计思路: 1.页面加载时,自动生成验证码. 2.后JS判定验证码是否输入正确 优点: 代码简洁,便于使用.页面中可直接判定验证码的正确性,无需传到后台Action中. 缺点: 由于本验证码是由text制作,容易被浏览器抓取/手动copy,丢失了其本质特性(安全性). <script type="text/javascript"> var code ; //在全局 定义验证码 function createCode() { c

ansible部署tomcat8

其实大部分是参考别人的博文做的,自己做了修改 准备 tomcat.tar.gz 经过优化后的 参考 http://vekergu.blog.51cto.com/9966832/1672931进行优化 apr模式开启 tomcat都使用root默认目录 文件 tomcat.sh server.xml 建立一些目录,并赋予权限 /opt/src/logs 启动 sh /opt/ea/tomcat.sh cat tomcat.sh #!/bin/bash JAVA_OPTS="-Xms2048m -X

ansible部署tomcat8 第二版

能用,写的太差 更新点 把项目和tomcat启动程序分开 加点变量 1.cat roles/http/tasks/main.yml - name: pro   file: path=/opt/apps/{{pro_dir}} state=directory - name: copy profile   copy: src=/opt/src/profile dest=/etc/profile force=yes owner=root group=root mode=0644 - name: cop