使用maven将代码到私服
在上一节中,我们讲述了maven私服搭建 ,那么本章,我们讲述如何使用maven将代码打包并上传到maven私服上。
一、maven pom.xml关键配置信息。
<distributionManagement>
<repository>
<id>releases</id>
<name>Nexus Release Repository</name>
<url>http://192.9.104.17:8081/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<name>Nexus Snapshot Repository</name>
<url>http://192.9.104.17:8081/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
二、maven 代码编译、打包、生成java doc相关配置
<build>
<plugins> <plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<configuration>
<url>http://192.9.104.116:8090/manager</url>
<server>tomcat-remote-deploy</server>
<path>/search-web</path>
</configuration>
</plugin> <plugin> <groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.7</version>
<configuration>
<connectors>
<connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
<port>8888</port>
<maxIdleTime>30000</maxIdleTime>
</connector>
</connectors>
<!--
<webAppSourceDirectory>${project.build.directory}/${pom.artifactId}-${pom.version}</webAppSourceDirectory> -->
<webApp>
<contextPath>/search</contextPath>
</webApp>
</configuration>
</plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>${plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>${plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>${plugin.version}</version>
<executions>
<execution>
<id>attach-sources</id>
<phase>verify</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${plugin.version}</version>
<!-- <version>2.1.2</version> -->
<configuration>
<source>1.6</source>
<target>1.6</target>
<complianceLevel>1.6</complianceLevel>
</configuration>
</plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>${java.doc.version}</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
其中:
maven-clean-plugin 执行mvn clean 命令相关插件
maven-resources-plugin 执行mvn 工程resources打包管理
maven-source-plugin 执行maven 代码源码打包的工具
maven-compiler-plugin maven代码编译的工具
maven-javadoc-plugin 生成javadoc的maven工具
tomcat-maven-plugin 进行tomcat远程部署的工具,主要配置的信息<server>tomcat-remote-deploy</server>就是setting.xml中servers中的配置信息,用户名和密码配置以后,就可以远程部署。
三、maven上传jar包到nexus私服。
1、创建maven执行命令。
点击Debug>>Debug configurations>>
点击执行按钮:
查看执行情况(见eclipse console):
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.tianditu.search:search-nlp:jar:0.1
[WARNING] 'build.plugins.plugin.version' for org.codehaus.mojo:tomcat-maven-plugin is missing. @ com.tianditu.search:tianditu-search:0.8, P:\ts_search\tianditu-search\pom.xml, line 62, column 14
[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] ------------------------------------------------------------------------
[INFO] Building search-nlp 0.1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.4:resources (default-resources) @ search-nlp ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.4:compile (default-compile) @ search-nlp ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.4:testResources (default-testResources) @ search-nlp ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory P:\ts_search\tianditu-search\search-nlp\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.4:testCompile (default-testCompile) @ search-nlp ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.7.1:test (default-test) @ search-nlp ---
[INFO] No tests to run.
[INFO] Surefire report directory: P:\ts_search\tianditu-search\search-nlp\target\surefire-reports -------------------------------------------------------
T E S T S
-------------------------------------------------------
There are no tests to run. Results : Tests run: 0, Failures: 0, Errors: 0, Skipped: 0 [INFO]
[INFO] --- maven-jar-plugin:2.3.1:jar (default-jar) @ search-nlp ---
[INFO] Building jar: P:\ts_search\tianditu-search\search-nlp\target\search-nlp-0.1.jar
[INFO]
[INFO] --- maven-javadoc-plugin:2.7:jar (attach-javadocs) @ search-nlp ---
[ERROR] Error fetching link: http://java.sun.com/javase/6/docs/api/package-list. Ignored it.
[INFO]
正在加载程序包com.tianditu.search.nlp的源文件...
正在构造 Javadoc 信息...
标准 Doclet 版本 1.7.0_45
正在构建所有程序包和类的树...
正在生成P:\ts_search\tianditu-search\search-nlp\target\apidocs\com\tianditu\search\nlp\BCConvert.html...
正在生成P:\ts_search\tianditu-search\search-nlp\target\apidocs\com\tianditu\search\nlp\Pinyin.html...
正在生成P:\ts_search\tianditu-search\search-nlp\target\apidocs\com\tianditu\search\nlp\StringTool.html...
正在生成P:\ts_search\tianditu-search\search-nlp\target\apidocs\com\tianditu\search\nlp\package-frame.html...
正在生成P:\ts_search\tianditu-search\search-nlp\target\apidocs\com\tianditu\search\nlp\package-summary.html...
正在生成P:\ts_search\tianditu-search\search-nlp\target\apidocs\com\tianditu\search\nlp\package-tree.html...
正在生成P:\ts_search\tianditu-search\search-nlp\target\apidocs\constant-values.html...
正在生成P:\ts_search\tianditu-search\search-nlp\target\apidocs\com\tianditu\search\nlp\class-use\StringTool.html...
正在生成P:\ts_search\tianditu-search\search-nlp\target\apidocs\com\tianditu\search\nlp\class-use\Pinyin.html...
正在生成P:\ts_search\tianditu-search\search-nlp\target\apidocs\com\tianditu\search\nlp\class-use\BCConvert.html...
正在生成P:\ts_search\tianditu-search\search-nlp\target\apidocs\com\tianditu\search\nlp\package-use.html...
正在构建所有程序包和类的索引...
正在生成P:\ts_search\tianditu-search\search-nlp\target\apidocs\overview-tree.html...
正在生成P:\ts_search\tianditu-search\search-nlp\target\apidocs\index-all.html...
正在生成P:\ts_search\tianditu-search\search-nlp\target\apidocs\deprecated-list.html...
正在构建所有类的索引...
正在生成P:\ts_search\tianditu-search\search-nlp\target\apidocs\allclasses-frame.html...
正在生成P:\ts_search\tianditu-search\search-nlp\target\apidocs\allclasses-noframe.html...
正在生成P:\ts_search\tianditu-search\search-nlp\target\apidocs\index.html...
正在生成P:\ts_search\tianditu-search\search-nlp\target\apidocs\help-doc.html...
7 个警告
[WARNING] Javadoc Warnings
[WARNING] P:\ts_search\tianditu-search\search-nlp\src\main\java\com\tianditu\search\nlp\StringTool.java:107: 警告 - @return 标记没有参数。
[WARNING] P:\ts_search\tianditu-search\search-nlp\src\main\java\com\tianditu\search\nlp\StringTool.java:127: 警告 - @return 标记没有参数。
[WARNING] P:\ts_search\tianditu-search\search-nlp\src\main\java\com\tianditu\search\nlp\StringTool.java:148: 警告 - @return 标记没有参数。
[WARNING] P:\ts_search\tianditu-search\search-nlp\src\main\java\com\tianditu\search\nlp\StringTool.java:171: 警告 - @return 标记没有参数。
[WARNING] P:\ts_search\tianditu-search\search-nlp\src\main\java\com\tianditu\search\nlp\StringTool.java:359: 警告 - @return 标记没有参数。
[WARNING] P:\ts_search\tianditu-search\search-nlp\src\main\java\com\tianditu\search\nlp\StringTool.java:73: 警告 - @note是未知标记。
[WARNING] P:\ts_search\tianditu-search\search-nlp\src\main\java\com\tianditu\search\nlp\StringTool.java:91: 警告 - @note是未知标记。
[INFO] Building jar: P:\ts_search\tianditu-search\search-nlp\target\search-nlp-0.1-javadoc.jar
[INFO]
[INFO] --- maven-source-plugin:2.4:jar-no-fork (attach-sources) @ search-nlp ---
[INFO] Building jar: P:\ts_search\tianditu-search\search-nlp\target\search-nlp-0.1-sources.jar
[INFO]
[INFO] --- maven-install-plugin:2.3.1:install (default-install) @ search-nlp ---
[INFO] Installing P:\ts_search\tianditu-search\search-nlp\target\search-nlp-0.1.jar to C:\Users\GCZX-016\.m2\repository\com\tianditu\search\search-nlp\0.1\search-nlp-0.1.jar
[INFO] Installing P:\ts_search\tianditu-search\search-nlp\pom.xml to C:\Users\GCZX-016\.m2\repository\com\tianditu\search\search-nlp\0.1\search-nlp-0.1.pom
[INFO] Installing P:\ts_search\tianditu-search\search-nlp\target\search-nlp-0.1-javadoc.jar to C:\Users\GCZX-016\.m2\repository\com\tianditu\search\search-nlp\0.1\search-nlp-0.1-javadoc.jar
[INFO] Installing P:\ts_search\tianditu-search\search-nlp\target\search-nlp-0.1-sources.jar to C:\Users\GCZX-016\.m2\repository\com\tianditu\search\search-nlp\0.1\search-nlp-0.1-sources.jar
[INFO]
[INFO] --- maven-deploy-plugin:2.5:deploy (default-deploy) @ search-nlp ---
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Uploading: http://192.9.104.17:8081/nexus/content/repositories/releases/com/tianditu/search/search-nlp/0.1/search-nlp-0.1.jar
Uploading: http://192.9.104.17:8081/nexus/content/repositories/releases/com/tianditu/search/search-nlp/0.1/search-nlp-0.1.pom
Uploaded: http://192.9.104.17:8081/nexus/content/repositories/releases/com/tianditu/search/search-nlp/0.1/search-nlp-0.1.jar (30 KB at 137.9 KB/sec)
Uploaded: http://192.9.104.17:8081/nexus/content/repositories/releases/com/tianditu/search/search-nlp/0.1/search-nlp-0.1.pom (5 KB at 46.4 KB/sec)
Downloading: http://192.9.104.17:8081/nexus/content/repositories/releases/com/tianditu/search/search-nlp/maven-metadata.xml
Downloaded: http://192.9.104.17:8081/nexus/content/repositories/releases/com/tianditu/search/search-nlp/maven-metadata.xml (305 B at 8.1 KB/sec)
Uploading: http://192.9.104.17:8081/nexus/content/repositories/releases/com/tianditu/search/search-nlp/maven-metadata.xml
Uploaded: http://192.9.104.17:8081/nexus/content/repositories/releases/com/tianditu/search/search-nlp/maven-metadata.xml (305 B at 0.6 KB/sec)
Uploading: http://192.9.104.17:8081/nexus/content/repositories/releases/com/tianditu/search/search-nlp/0.1/search-nlp-0.1-javadoc.jar
Uploaded: http://192.9.104.17:8081/nexus/content/repositories/releases/com/tianditu/search/search-nlp/0.1/search-nlp-0.1-javadoc.jar (47 KB at 649.1 KB/sec)
Uploading: http://192.9.104.17:8081/nexus/content/repositories/releases/com/tianditu/search/search-nlp/0.1/search-nlp-0.1-sources.jar
Uploaded: http://192.9.104.17:8081/nexus/content/repositories/releases/com/tianditu/search/search-nlp/0.1/search-nlp-0.1-sources.jar (23 KB at 340.6 KB/sec)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.709s
[INFO] Finished at: Thu Jun 04 17:26:55 CST 2015
[INFO] Final Memory: 18M/386M
[INFO] ------------------------------------------------------------------------
如有错误,然后定位并解决,主要错误就是用户没有权限,或者仓库地址没有配置等等。
使用maven将代码到私服的更多相关文章
- 07 Maven 使用Nexus创建私服
7. Maven 使用Nexus创建私服 私服不是 Maven 的核心概念,它仅仅是一种衍生出来的特殊的 Maven 仓库.通过建立自己的私服,就可以降低中央仓库负荷.节省外网带宽.加速 Maven ...
- maven项目如何从私服nexus中下载依赖包
maven项目如何从私服nexus中下载依赖包 解决方法: 1.打开maven的config目录中settings.xml文件 2.在<profile></profiles> ...
- maven发布项目到私服-snapshot快照库和release发布库的区别和作用及maven常用命令
maven发布项目到私服-snapshot快照库和release发布库的区别和作用及maven常用命令 在日常的工作中由于各种原因,会出现这样一种情况,某些项目并没有打包至mvnrepository. ...
- Linux安装配置maven以及搭建nexus私服(编写启动脚本)
2011年07月12日16:32 下面介绍在Linux操作系统下安装配置maven和搭建nexus私服. 一.安装前的准备 下载 jdk http://www.oracle.com/technetw ...
- 使用Maven部署构件至私服
--------------------siwuxie095 使用 Maven 部署构件至私服 1.部署构件到 Nexu ...
- Maven编译代码的时候跳过单元测试
Maven编译代码的时候跳过单元测试 <properties> <maven.test.skip>true</maven.test.skip> </prope ...
- MAVEN学习笔记之私服Nexus(2)
MAVEN学习笔记之私服Nexus(2) 私有服务器搭建 Nexus www.snatype.org下载 snatype-work 是默认nexus存储nexus a:将bin添加到环境中 Admin ...
- maven仓库--搭建局域网私服(windows版)
使用nexus搭建局域网私服 一. 认识maven仓库 1.1 maven仓库的作用 回想之前不用maven的时候,我们用eclipse原始的项目骨架构建项目时,在工程目录下往往有一个lib文件夹 ...
- 【Maven学习】Nexus私服代理其他第三方的Maven仓库
一.背景 [Maven学习]Nexus OSS私服仓库的安装和配置 http://blog.csdn.net/ouyang_peng/article/details/78793038 [Maven学习 ...
随机推荐
- 神奇的CSS3按钮特效
点击这里查看效果 以下是源代码: <!doctype html> <html> <!-- author: @simurai --> <head> < ...
- Redis 详解 (一) StackExchange.Redis Client
这期我们来看StackExchange.Redis,这是redis 的.net客户端之一.Redis是一个开源的内存数据存储,可以用来做数据库,缓存或者消息代理服务.目前有不少人在使用ServiceS ...
- Unity3D 5.x 交互功能 - 碰撞检测函数
1,给第一人称控制器添加脚本:playercollisions.js 脚本中只定义变量,先不添加方法: #pragma strict var door_open_time:float=3.0; var ...
- PHP intval()
定义和用法 获取变量的整数值,允许以使用特定的进制返回.默认10进制 注:如果参数为整数,则不做任何处理. 语法 intval (var, base) 参数 描述 var 必须.可以是任何标量类型. ...
- codeforces 632+ E. Thief in a Shop
E. Thief in a Shop time limit per test 5 seconds memory limit per test 512 megabytes input standard ...
- 从零开始学 Java - 数据库连接池的选择 Druid
我先说说数据库连接 数据库大家都不陌生,从名字就能看出来它是「存放数据的仓库」,那我们怎么去「仓库」取东西呢?当然需要钥匙啦!这就是我们的数据库用户名.密码了,然后我们就可以打开门去任意的存取东西了. ...
- Atitit.提升 升级类库框架后的api代码兼容性设计指南
Atitit.提升 升级类库框架后的api代码兼容性设计指南 1. 增加api直接增加,版本号在注释上面增加1 2. 废弃api,使用主见@dep1 3. 修改api,1 4. 修改依赖import, ...
- 字符编码笔记:ASCII,Unicode和UTF-8
很久很久以前,有一群人,他们决定用8个可以开合的晶体管来组合成不同的状态,以表示世界上的万物.他们看到8个开关状态是好的,于是他们把这称为"字节". 再后来,他们又做了一些可以处理 ...
- HTML字符实体(关于 ><等)
常用字符实体 注意:实体名称是区分大小写的! 结果 描述 实体名 实体编号 non-breaking space < less than < < > greate ...
- 分享20个最新的免费 UI 设计素材给设计师
用户界面设计涉及到很多的创意,灵感以及需要与客户进行有效沟通的技能.良好的用户界面是一致的,可以使网站更容易理解和使用.UI设计的重点在于用户体验和互动,同时易于使用对于一个成功的移动应用程序来说非常 ...