一、软件安装

  地址:http://www.sonatype.org/nexus/thank-you-for-downloading/?dl=tgz

  解压:

    

启动:

     >> nexus start

  打开:http://192.9.104.17:8081/nexus/#welcome

     

   点击右上角,使用admin/admin123(默认管理员)登陆。

   管理操作面板(修改代码库、镜像、用户权限管理等):

     

     

二、系统配置

  默认的nexus 配置的镜像是无法使用的,需要我们把它设置为可行的,重新构建索引。

  重新构建索引:

    

  需要修改的仓库有三处:Central、Apache Snapshots、Codehaus Snapshots

  另外,releases和snapshots两处的可以自动部署属性必须勾上,如下图:

    

  当然,你也可以通过界面来上传jar包。

    

三、maven环境配置

  1、确保你的环境中已经部署和正确配置了maven环境,具体如果安装maven不在此教程范畴之内。

  2、到你当前登录的用户下的.m2目录下,创建一个setting.xml,内容如下:

    

  1. <?xml version="1.0" encoding="UTF-8"?>
  2.  
  3. <!--
  4. Licensed to the Apache Software Foundation (ASF) under one
  5. or more contributor license agreements. See the NOTICE file
  6. distributed with this work for additional information
  7. regarding copyright ownership. The ASF licenses this file
  8. to you under the Apache License, Version 2.0 (the
  9. "License"); you may not use this file except in compliance
  10. with the License. You may obtain a copy of the License at
  11.  
  12. http://www.apache.org/licenses/LICENSE-2.0
  13.  
  14. Unless required by applicable law or agreed to in writing,
  15. software distributed under the License is distributed on an
  16. "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  17. KIND, either express or implied. See the License for the
  18. specific language governing permissions and limitations
  19. under the License.
  20. -->
  21.  
  22. <!--
  23. | This is the configuration file for Maven. It can be specified at two levels:
  24. |
  25. | 1. User Level. This settings.xml file provides configuration for a single user,
  26. | and is normally provided in ${user.home}/.m2/settings.xml.
  27. |
  28. | NOTE: This location can be overridden with the CLI option:
  29. |
  30. | -s /path/to/user/settings.xml
  31. |
  32. | 2. Global Level. This settings.xml file provides configuration for all Maven
  33. | users on a machine (assuming they're all using the same Maven
  34. | installation). It's normally provided in
  35. | ${maven.home}/conf/settings.xml.
  36. |
  37. | NOTE: This location can be overridden with the CLI option:
  38. |
  39. | -gs /path/to/global/settings.xml
  40. |
  41. | The sections in this sample file are intended to give you a running start at
  42. | getting the most out of your Maven installation. Where appropriate, the default
  43. | values (values used when the setting is not specified) are provided.
  44. |
  45. |-->
  46. <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  47. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  48. xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
  49. <!-- localRepository
  50. | The path to the local repository maven will use to store artifacts.
  51. |
  52. | Default: ${user.home}/.m2/repository
  53. <localRepository>/path/to/local/repo</localRepository>
  54. -->
  55.  
  56. <!-- interactiveMode
  57. | This will determine whether maven prompts you when it needs input. If set to false,
  58. | maven will use a sensible default value, perhaps based on some other setting, for
  59. | the parameter in question.
  60. |
  61. | Default: true
  62. <interactiveMode>true</interactiveMode>
  63. -->
  64.  
  65. <!-- offline
  66. | Determines whether maven should attempt to connect to the network when executing a build.
  67. | This will have an effect on artifact downloads, artifact deployment, and others.
  68. |
  69. | Default: false
  70. <offline>false</offline>
  71. -->
  72.  
  73. <!-- pluginGroups
  74. | This is a list of additional group identifiers that will be searched when resolving plugins by their prefix, i.e.
  75. | when invoking a command line like "mvn prefix:goal". Maven will automatically add the group identifiers
  76. | "org.apache.maven.plugins" and "org.codehaus.mojo" if these are not already contained in the list.
  77. |-->
  78. <pluginGroups>
  79. <!-- pluginGroup
  80. | Specifies a further group identifier to use for plugin lookup.
  81. <pluginGroup>com.your.plugins</pluginGroup>
  82. -->
  83. </pluginGroups>
  84.  
  85. <!-- proxies
  86. | This is a list of proxies which can be used on this machine to connect to the network.
  87. | Unless otherwise specified (by system property or command-line switch), the first proxy
  88. | specification in this list marked as active will be used.
  89. |-->
  90. <proxies>
  91. <!-- proxy
  92. | Specification for one proxy, to be used in connecting to the network.
  93. |
  94. <proxy>
  95. <id>optional</id>
  96. <active>true</active>
  97. <protocol>http</protocol>
  98. <username>proxyuser</username>
  99. <password>proxypass</password>
  100. <host>proxy.host.net</host>
  101. <port>80</port>
  102. <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
  103. </proxy>
  104. -->
  105. </proxies>
  106.  
  107. <!-- servers
  108. | This is a list of authentication profiles, keyed by the server-id used within the system.
  109. | Authentication profiles can be used whenever maven must make a connection to a remote server.
  110. |-->
  111. <servers>
  112. <!-- server
  113. | Specifies the authentication information to use when connecting to a particular server, identified by
  114. | a unique name within the system (referred to by the 'id' attribute below).
  115. |
  116. | NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are
  117. | used together.
  118. |
  119. <server>
  120. <id>deploymentRepo</id>
  121. <username>repouser</username>
  122. <password>repopwd</password>
  123. </server>
  124. -->
  125.  
  126. <!-- Another sample, using keys to authenticate.
  127. <server>
  128. <id>siteServer</id>
  129. <privateKey>/path/to/private/key</privateKey>
  130. <passphrase>optional; leave empty if not used.</passphrase>
  131. </server>
  132. -->
  133. <server>
  134. <id>snapshots</id>
  135. <username>likehua</username>
  136. <password>likehua</password>
  137. </server>
  138. <server>
  139. <id>releases</id>
  140. <username>likehua</username>
  141. <password>likehua</password>
  142. </server>
  143.  
  144. <server>
  145. <id>tomcat-remote-deploy</id>
  146. <username>tomcat</username>
  147. <password>tomcat123</password>
  148. </server>
  149. </servers>
  150.  
  151. <!-- mirrors
  152. | This is a list of mirrors to be used in downloading artifacts from remote repositories.
  153. |
  154. | It works like this: a POM may declare a repository to use in resolving certain artifacts.
  155. | However, this repository may have problems with heavy traffic at times, so people have mirrored
  156. | it to several places.
  157. |
  158. | That repository definition will have a unique id, so we can create a mirror reference for that
  159. | repository, to be used as an alternate download site. The mirror site will be the preferred
  160. | server for that repository.
  161. |-->
  162. <mirrors>
  163. <!-- mirror
  164. | Specifies a repository mirror site to use instead of a given repository. The repository that
  165. | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
  166. | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
  167. |
  168. <mirror>
  169. <id>mirrorId</id>
  170. <mirrorOf>repositoryId</mirrorOf>
  171. <name>Human Readable Name for this Mirror.</name>
  172. <url>http://my.repository.com/repo/path</url>
  173. </mirror>
  174. -->
  175. <mirror>
  176. <id>nexus</id>
  177. <mirrorOf>*</mirrorOf>
  178. <name>A Local Nexus Server</name>
  179. <url>http://192.9.104.17:8081/nexus/content/groups/public/</url>
  180. </mirror>
  181. </mirrors>
  182.  
  183. <!-- profiles
  184. | This is a list of profiles which can be activated in a variety of ways, and which can modify
  185. | the build process. Profiles provided in the settings.xml are intended to provide local machine-
  186. | specific paths and repository locations which allow the build to work in the local environment.
  187. |
  188. | For example, if you have an integration testing plugin - like cactus - that needs to know where
  189. | your Tomcat instance is installed, you can provide a variable here such that the variable is
  190. | dereferenced during the build process to configure the cactus plugin.
  191. |
  192. | As noted above, profiles can be activated in a variety of ways. One way - the activeProfiles
  193. | section of this document (settings.xml) - will be discussed later. Another way essentially
  194. | relies on the detection of a system property, either matching a particular value for the property,
  195. | or merely testing its existence. Profiles can also be activated by JDK version prefix, where a
  196. | value of '1.4' might activate a profile when the build is executed on a JDK version of '1.4.2_07'.
  197. | Finally, the list of active profiles can be specified directly from the command line.
  198. |
  199. | NOTE: For profiles defined in the settings.xml, you are restricted to specifying only artifact
  200. | repositories, plugin repositories, and free-form properties to be used as configuration
  201. | variables for plugins in the POM.
  202. |
  203. |-->
  204. <profiles>
  205. <!-- profile
  206. | Specifies a set of introductions to the build process, to be activated using one or more of the
  207. | mechanisms described above. For inheritance purposes, and to activate profiles via <activatedProfiles/>
  208. | or the command line, profiles have to have an ID that is unique.
  209. |
  210. | An encouraged best practice for profile identification is to use a consistent naming convention
  211. | for profiles, such as 'env-dev', 'env-test', 'env-production', 'user-jdcasey', 'user-brett', etc.
  212. | This will make it more intuitive to understand what the set of introduced profiles is attempting
  213. | to accomplish, particularly when you only have a list of profile id's for debug.
  214. |
  215. | This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo.
  216. <profile>
  217. <id>jdk-1.4</id>
  218.  
  219. <activation>
  220. <jdk>1.4</jdk>
  221. </activation>
  222.  
  223. <repositories>
  224. <repository>
  225. <id>jdk14</id>
  226. <name>Repository for JDK 1.4 builds</name>
  227. <url>http://www.myhost.com/maven/jdk14</url>
  228. <layout>default</layout>
  229. <snapshotPolicy>always</snapshotPolicy>
  230. </repository>
  231. </repositories>
  232. </profile>
  233. -->
  234.  
  235. <profile>
  236. <id>nexus</id>
  237. <repositories>
  238. <repository>
  239. <releases><enabled>true</enabled></releases>
  240. <snapshots><enabled>true</enabled></snapshots>
  241. <id>nexus</id>
  242. <name>Repository for Local Nexus Server</name>
  243. <url>http://central</url>
  244. <layout>default</layout>
  245. </repository>
  246. </repositories>
  247. <pluginRepositories>
  248. <pluginRepository>
  249. <releases><enabled>true</enabled></releases>
  250. <snapshots><enabled>true</enabled></snapshots>
  251. <id>nexus</id>
  252. <name>Plugin Repository for Local Nexus Server</name>
  253. <url>http://central</url>
  254. </pluginRepository>
  255. </pluginRepositories>
  256. </profile>
  257.  
  258. <!--
  259. | Here is another profile, activated by the system property 'target-env' with a value of 'dev',
  260. | which provides a specific path to the Tomcat instance. To use this, your plugin configuration
  261. | might hypothetically look like:
  262. |
  263. | ...
  264. | <plugin>
  265. | <groupId>org.myco.myplugins</groupId>
  266. | <artifactId>myplugin</artifactId>
  267. |
  268. | <configuration>
  269. | <tomcatLocation>${tomcatPath}</tomcatLocation>
  270. | </configuration>
  271. | </plugin>
  272. | ...
  273. |
  274. | NOTE: If you just wanted to inject this configuration whenever someone set 'target-env' to
  275. | anything, you could just leave off the <value/> inside the activation-property.
  276. |
  277. <profile>
  278. <id>env-dev</id>
  279.  
  280. <activation>
  281. <property>
  282. <name>target-env</name>
  283. <value>dev</value>
  284. </property>
  285. </activation>
  286.  
  287. <properties>
  288. <tomcatPath>/path/to/tomcat/instance</tomcatPath>
  289. </properties>
  290. </profile>
  291. -->
  292. </profiles>
  293.  
  294. <!-- activeProfiles
  295. | List of profiles that are active for all builds.
  296. |
  297. <activeProfiles>
  298. <activeProfile>alwaysActiveProfile</activeProfile>
  299. <activeProfile>anotherAlwaysActiveProfile</activeProfile>
  300. </activeProfiles>
  301. -->
  302. </settings>

主要注意修改:servers和mirrors两处,如本例所示:

  servers:

  

  1. <servers>
  2. <!-- server
  3. | Specifies the authentication information to use when connecting to a particular server, identified by
  4. | a unique name within the system (referred to by the 'id' attribute below).
  5. |
  6. | NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are
  7. | used together.
  8. |
  9. <server>
  10. <id>deploymentRepo</id>
  11. <username>repouser</username>
  12. <password>repopwd</password>
  13. </server>
  14. -->
  15.  
  16. <!-- Another sample, using keys to authenticate.
  17. <server>
  18. <id>siteServer</id>
  19. <privateKey>/path/to/private/key</privateKey>
  20. <passphrase>optional; leave empty if not used.</passphrase>
  21. </server>
  22. -->
  23. <server>
  24. <id>snapshots</id>
  25. <username>likehua</username>
  26. <password>likehua</password>
  27. </server>
  28. <server>
  29. <id>releases</id>
  30. <username>likehua</username>
  31. <password>likehua</password>
  32. </server>
  33.  
  34. <server>
  35. <id>tomcat-remote-deploy</id>
  36. <username>tomcat</username>
  37. <password>tomcat123</password>
  38. </server>
  39. </servers>

  注意此处的用户名和密码,是你nexus上创建的用户名,一般付给部署的权限。

  另外就是镜像地址的配置:

  1. <mirrors>
  2. <!-- mirror
  3. | Specifies a repository mirror site to use instead of a given repository. The repository that
  4. | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
  5. | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
  6. |
  7. <mirror>
  8. <id>mirrorId</id>
  9. <mirrorOf>repositoryId</mirrorOf>
  10. <name>Human Readable Name for this Mirror.</name>
  11. <url>http://my.repository.com/repo/path</url>
  12. </mirror>
  13. -->
  14. <mirror>
  15. <id>nexus</id>
  16. <mirrorOf>*</mirrorOf>
  17. <name>A Local Nexus Server</name>
  18. <url>http://192.9.104.17:/nexus/content/groups/public/</url>
  19. </mirror>
  20. </mirrors>

ok,maven私服搭建配置完成。

maven私服搭建的更多相关文章

  1. maven私服搭建(centOS6.5)

    maven的好处和私服的应用本文不赘述,私服搭建如下: MAVEN 私服搭建(centOS 6.5 环境) 1.  准备环境,搭建centOS6.5系统环境,略 2.  准备对应的软件包如下: A. ...

  2. maven仓库总结,maven私服搭建

    配置pom.xml依赖包时在这里找包的描述: http://search.maven.org/#browse 以java为根目录. mvn archtype:generate -DgroupId=zt ...

  3. window Maven私服搭建——nexus

    注:本文来源于 <window   Maven私服搭建--nexus> Maven私服搭建--nexus 1.下载nexus https://www.sonatype.com/downlo ...

  4. maven仓库总结,maven私服搭建,批量mvn eclipse:eclipse

    配置pom.xml依赖包时在这里找包的描述: http://search.maven.org/#browse 以java为根目录. mvn archtype:generate -DgroupId=zt ...

  5. maven私服搭建&使用

    Maven私服搭建教程 一.nexus安装 1,解压安装包 安装包下载地址 2,以管理员身份打开cmd 3,进入到nexus的bin目录 (1) 安装:nexus install (2) 启动:nex ...

  6. linux7下nenux3.14的maven私服搭建和配置使用

    为什么用私服,各种帖子很多,话不多说,直接奉上本博主的搭建过程. 一.环境准备:确保jdk和maven安装完成 二.下载nenux:地址:https://www.sonatype.com/downlo ...

  7. Nexus Maven 私服搭建

    1.下载Nexus安装文件:http://www.sonatype.org/nexus/go ,目前是nexus-2.13.0-01-bundle.tar.zip这个最新版本: 2.解压到任意目录,我 ...

  8. linux环境下jdk 安装以及maven私服搭建

    1:准备资源      linux服务器,jdk和nexus  安装包    2:网络通畅,保持windows端和linux服务器端网络通畅.     3: 安装jdk和配置环境变量      进入到 ...

  9. maven私服搭建nexus/windows/linux(一)

    为什么要搭建nexus私服,原因很简单,有些公司都不提供外网给项目组人员,因此就不能使用maven访问远程的仓库地址,还有就是公司内部开发的一些版本的jar包,如果没有私服需要一人拷贝一份然后再自己安 ...

随机推荐

  1. 离线安装swashbuckle(webapi自动文档及测试工具)

    1.找到已经成功安装过的项目根目录的packages文件夹拷贝到新的项目的根目录 2.vs设置nuget程序包源 将源:地址改为新项目的packages文件夹 3.重新编译并修改代码 右键项目-> ...

  2. [moka同学笔记]Linux命令基本格式及目录处理命令

    命令提示符 [root@localhost ~]# root:当前登录用户localhost:主机名~:当前所在的目录,此处为"家"目录#:root超级用户的提示符,如果是普通用户 ...

  3. java jni c++ 例子

    1. java程序 public class TestHello { static { System.loadLibrary("TestHello"); } public stat ...

  4. Java--Jsp内置对象列表

  5. Three.js基础部分学习

    一.关于使用Three.js几点理论说明 1.请参考官网地址 https://threejs.org/ 2.使用three.js必备条件 <场景 A scene.相机a camera.渲染器 a ...

  6. Html之 IFrame使用,注意几点

    0x01 iframe的跳出框架 0x02 iframe样式设置 0x03 iframe重置高度 1.首先来一个,跳出iframe的好方法,直接可以在Login.aspx页面使用. if (windo ...

  7. HTML 定时页面跳转

    有 2 种方法可以实现 html 的定时页面跳转,1.meta refresh 实现.2.JavaScript 实现. 1.通过 meta refresh 实现 3 秒后自动跳转到 http://ww ...

  8. jquery编写插件的方法

     版权声明:作者原创,转载请注明出处! 编写插件的两种方式: 1.类级别开发插件(1%) 2.对象级别开发(99%) 类级别的静态开发就是给jquery添加静态方法,三种方式 1.添加新的全局函数 2 ...

  9. 基本排序算法——shell排序java实现

    shell排序是对插入排序的一种改进. package basic.sort; import java.util.Arrays; import java.util.Random; public cla ...

  10. sqlite 数据类型

    title: SQLITE 数据类型date: 2015-11-20 20:30:52categories: IOS tags: sqlite数据类型 小小程序猿我的博客:http://daycodi ...