posts - 167,  comments - 30,  trackbacks - 0

maven大家都了解了是个什么玩意儿,直接上部署过程了。
新建个目录mkdir /data/maven, 
进入该目录并执行如下操作步骤:

maven官网下载包:

#wget http://mirror.bit.edu.cn/apache/maven/maven-3/3.1.1/binaries/apache-maven-3.1.1-bin.tar.gz

 解压maven

# tar -zxvf apache-maven-3.1.1-bin.tar.gz

 进入apache-maven-3.1.1,新建隐藏目录.m2(mkdir .m2),再在该.m2目录下创建setting.xml文件,文件内容如下:

<?xml version="1.0" encoding="UTF-8"?>

<settings xmlns=http://maven.apache.org/SETTINGS/1.0.0

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0

http://maven.apache.org/xsd/settings-1.0.0.xsd">

<!-- 指定jar包存放路径-->

<localRepository>/data/maven/apache-maven-3.1.1/repo/</localRepository>

<pluginGroups> </pluginGroups> <!--设置代理服务器 -->

<proxies> <proxy>

<id>my-proxy</id>

<active>true</active>

<protocol>http</protocol>

<host>202.84.17.41</host>

<port>8080</port>

</proxy> </proxies>

<!-- 设置私服server-->

<servers>

<server>

<id>nexus</id>

<username>admin</username>

<password>admin</password>

</server> </servers> <!-- 配置私服作为镜像,只允许maven使用私服--> <mirrors>

<mirror>

<id>nexus</id>

<mirrorOf>*</mirrorOf>

<url>http://localhost:8081/nexus/content/groups/public</url>

</mirror> </mirrors> <profiles>

<profile>

<id>nexus</id>

<repositories>

<repository>

<id>central</id>

<url>http://central</url>

<releases><enabled>true</enabled></releases>

<snapshots><enabled>true</enabled></snapshots>

</repository>

</repositories>

<pluginRepositories>

<pluginRepository>

<id>central</id>

<url>http://central</url>

<releases><enabled>true</enabled></releases>

<snapshots><enabled>true</enabled></snapshots>

</pluginRepository>

</pluginRepositories>

</profile>

</profiles>

<activeProfiles>

<activeProfile>nexus</activeProfile>

</activeProfiles></settings>

 Nexus所有版本下载地址:http://www.sonatype.org/nexus/archived

nexus官网下载最新的版本.

# wget http://www.sonatype.org/downloads/nexus-latest-bundle.tar.gz

 解压nexus

# tar -zxvf nexus-2.6.4-02-bundle.tar.gz

 启动脚本:

mavenStart.sh

#!/bin/bash

M2_HOME=/data/maven/apache-maven-3.1.1

JAVA_HOME=/usr/local/jdk/bin

export M2_HOME

PATH=$JAVA_HOME:$PATH:$HOME/bin:$M2_HOME/bin

export PATH

/data/maven/nexus-2.1.1/bin/jsw/linux-x86-64/nexus start

停止脚本:

mavenStop.sh

#!/bin/bash

/data/maven/nexus-2.1.1/bin/jsw/linux-x86-64/nexus stop

 正常启动nexus

# sh mavenStart.sh

****************************************

WARNING - NOT RECOMMENDED TO RUN AS ROOT

****************************************

Starting Nexus OSS...

Started Nexus OSS.

错误1:若出现如下错误:

***********************************

WARNING - NOT RECOMMENDED TO RUN AS ROOT

****************************************

If you insist running as root, then set the environment variable RUN_AS_USER=root before running this script

解决方式:修改$NEXUS_HOME/jsw/linuxx86-64/nexus文件中RUN_AS_USER=root

 错误2:启动几秒钟后,自动停止了nexus进程,报错如下:

Launching a JVM...

wrapper  | JVM exited while loading the application.

jvm 3    | Exception in thread "main" java.lang.UnsupportedClassVersionError: org/sonatype/nexus/bootstrap/jsw/JswLauncher : Unsupported major.minor version 51.0

jvm 3    |     at java.lang.ClassLoader.defineClass1(Native Method)

jvm 3    |     at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)

jvm 3    |     at java.lang.ClassLoader.defineClass(ClassLoader.java:616)

jvm 3    |     at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)

jvm 3    |     at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)

jvm 3    |     at java.net.URLClassLoader.access$000(URLClassLoader.java:58)

jvm 3    |     at java.net.URLClassLoader$1.run(URLClassLoader.java:197)

jvm 3    |     at java.security.AccessController.doPrivileged(Native Method)

jvm 3    |     at java.net.URLClassLoader.findClass(URLClassLoader.java:190)

jvm 3    |     at java.lang.ClassLoader.loadClass(ClassLoader.java:307)

jvm 3    |     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)

jvm 3    |     at java.lang.ClassLoader.loadClass(ClassLoader.java:248)

jvm 3    | Could not find the main class: org.sonatype.nexus.bootstrap.jsw.JswLauncher.  Program will exit.

解决方式:可能原因是jdk版本低 没有去下载jdk1.7,而是下载了nexus-2.1.1-bundle.tar.gz,测试了下,jdk1.6是完全支持滴~

 重新修改配置并启动:

浏览器中输入:http://IP:8081/nexus

显示界面如下:


默认用户名和密码:admin/admin123

点击左侧 Repositories,显示如下:

将如下三项目中的Configuration中的Download Remote indexs修改为true
 

然后,右键à选择Repair Index Nexus远程下载索引文件。


3rd party Configuration中的Deploment Policy修改为Allow Redeploy

以上就基本已将nexus私服配置完成。

通过选择Select Artifact(s) for upload,上传单独开发的jar包方式:



 二、 maven插件安装及nexus私服的使用:

我的电脑中以前已经安装过maven了,在控制台下输入mvn -version可以查看到当前maven版本:


修改D:\apache-maven-3.0.5\conf\setting.xml文件中变更maven repository地址。

默认是在用户本地临时目录下,我的是C:\Documents and Settings\server\.m2\repository

配置修改如下:

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"

          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">

  <!-- localRepository

   | The path to the local repository maven will use to store artifacts.

   |

   | Default: ~/.m2/repository

  <localRepository>/path/to/local/repo</localRepository>

  -->

  <localRepository>E:/maven/repo</localRepository>

  <!-- interactiveMode

   | This will determine whether maven prompts you when it needs input. If set to false,

   | maven will use a sensible default value, perhaps based on some other setting, for

   | the parameter in question.

   |

   | Default: true

  <interactiveMode>true</interactiveMode>

  -->

 控制台下,运行mvn help:system, 从远程仓库下载..


eclipse /Myeclipse安装插件的方式最常见的有两种:

    1. 一种是在线安装,这,貌似是用的最多的,就是:Help  -->  Install New Software,然后输入 HTTP 地址来安装,但有一个很明显的缺点,就是慢!
    2. 一种是离线安装,用 link 的方式来安装,这种方式可拔性更好,可以随时将插件插上和拔下,非常方便。

第二中方式可以参考博客:

http://www.blogjava.net/fancydeepin/archive/2012/07/13/382965.html

我比较倾向于使用Myeclipse高度集成化的工具.

安装成功后,工具中WindowsàPreferences


安装maven


 

配置setting.xml


 以上配置完成后,现有maven工程pom.xml文件中修改nexus私服地址后,会自动下载依赖的jar,控制台中不断输出信息:



posted on 2013-11-19 11:48 David1228 阅读(23699) 评论(1)  编辑  收藏 所属分类: JAVA其他

FeedBack:
# re: Maven及Nexus私服搭建[未登录]
2015-09-28 17:27 | Ron
谢谢,很有帮助!
在2.11.1版本中,启动文件路径变为:nexus-2.11.1-01/bin/nexus  回复  更多评论
  

只有注册用户登录后才能发表评论。


网站导航:
 

<2013年11月>
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567

常用链接

留言簿(4)

随笔分类

随笔档案

文章档案

新闻分类

新闻档案

相册

收藏夹

Java

Linux知识相关

Spring相关

云计算/Linux/虚拟化技术/

友情博客

多线程并发编程

开源技术

持久层技术相关

搜索

  •  

积分与排名

  • 积分 - 354520
  • 排名 - 155

最新评论

阅读排行榜

评论排行榜