MAVEN私服搭建

Maven私服搭建

1:启动nexus服务报错

搭建指南参考:http://wenku.baidu.com/view/8b709265caaedd3383c4d3f8.html

查看启动日志:D:\soft-hw\nexus-2.6.3-01-bundle\nexus-2.6.3-01\logs\

Waiting to start...
wrapper  | Reloading Wrapper configuration...
wrapper  | Launching a JVM...
jvm 5    | java.lang.UnsupportedClassVersionError: org/sonatype/nexus/bootstrap/jsw/JswLauncher : Unsupported major.minor version 51.0
jvm 5    |  at java.lang.ClassLoader.defineClass1(Native Method)
jvm 5    |  at java.lang.ClassLoader.defineClass(Unknown Source)
jvm 5    |  at java.security.SecureClassLoader.defineClass(Unknown Source)


原因是我的jdk版本是1.6. 太低。重新下载安装个1.7。启动正常

2:配置maven环境变量

本地maven客户端:D:\soft-hw\apache-maven-3.0.5-bin\apache-maven-3.0.5

设置maven环境变量。

检测本地maven是否ok:

maven -version

3:安装eclispe maven插件

在线安装方式

打开eclipse

2 Help – Install New Software

Add

m2e

http://m2eclipse.sonatype.org/sites/m2e

此路径已改为以下路径

http://download.eclipse.org/technology/m2e/releases 

 

报错:

Cannot complete the install because one or more required items could not be found.
  Software being installed: m2e - slf4j over logback logging (Optional) 1.4.0.20130601-0317 (org.eclipse.m2e.logback.feature.feature.group 1.4.0.20130601-0317)
  Missing requirement: Maven Integration for Eclipse 1.4.0.20130601-0317 (org.eclipse.m2e.core.ui 1.4.0.20130601-0317) requires 'bundle org.slf4j.api 1.6.2' but it could not be found
  Cannot satisfy dependency:
    From: m2e logback appender 1.4.0.20130601-0317 (org.eclipse.m2e.logback.appender 1.4.0.20130601-0317)
    To: bundle org.eclipse.m2e.core.ui [1.4.0,1.5.0)
  Cannot satisfy dependency:
    From: m2e - slf4j over logback logging (Optional) 1.4.0.20130601-0317 (org.eclipse.m2e.logback.feature.feature.group 1.4.0.20130601-0317)
To: org.eclipse.m2e.logback.appender [1.4.0.20130601-0317]


离线安装方式:

Eclispe maven插件:D:\soft-hw\maven-eclipse_plugin

dropins目录下创建文件夹maven3

把解压出的features目录和plugins目录放到dropins下的maven3里就可以了,不用link方式。

目录

eclipse3.7
--plugins
--features
--links
------xxx.link(或者是xxx.txt)
--dropins
------xxx
-----
-----plugins
----------features


测试

windows--首选项中有Maven

至此开发环境搭建完毕

4:构建maven项目

参考:http://www.blogjava.net/yxhxj2006/archive/2012/08/23/386144.html

Maven构建spring dm OSGI工程

失败尝试

使用这种方式构建后,在更新依赖的jar包时候报如下错误:

13-9-28 上午01时09分56秒: Maven Builder: FULL_BUILD 
13-9-28 上午01时09分56秒: [WARN] 
13-9-28 上午01时09分56秒: [WARN] Some problems were encountered while building the effective model for com.hrbeu.app:osgi:bundle:0.0.1-SNAPSHOT
13-9-28 上午01时09分56秒: [WARN] 'build.plugins.plugin.(groupId:artifactId)' must be unique but found duplicate declaration of plugin org.apache.felix:maven-bundle-plugin @ line 155, column 12
13-9-28 上午01时09分56秒: [WARN] 
13-9-28 上午01时09分56秒: [WARN] It is highly recommended to fix these problems because they threaten the stability of your build.
13-9-28 上午01时09分56秒: [WARN] 
13-9-28 上午01时09分56秒: [WARN] For this reason, future Maven versions might no longer support building such malformed projects.
13-9-28 上午01时09分56秒: [WARN] 
13-9-28 上午01时09分57秒: [WARN] Failure to transfer org.springframework.osgi:junit.osgi:3.8.2-SNAPSHOT/maven-metadata.xml from http://m2.safehaus.org was cached in the local repository, resolution will not be reattempted until the update interval of safehaus-repository has elapsed or updates are forced. Original error: Could not transfer metadata org.springframework.osgi:junit.osgi:3.8.2-SNAPSHOT/maven-metadata.xml from/to safehaus-repository (http://m2.safehaus.org): ConnectException
13-9-28 上午01时09分57秒: [WARN] Failure to transfer org.springframework.osgi:osgi-repo:1.0-SNAPSHOT/maven-metadata.xml from http://m2.safehaus.org was cached in the local repository, resolution will not be reattempted until the update interval of safehaus-repository has elapsed or updates are forced. Original error: Could not transfer metadata org.springframework.osgi:osgi-repo:1.0-SNAPSHOT/maven-metadata.xml from/to safehaus-repository (http://m2.safehaus.org): ConnectException
13-9-28 上午01时09分57秒: [WARN] Failure to transfer org.springframework.osgi:asm.osgi:2.2.3-SNAPSHOT/maven-metadata.xml from http://m2.safehaus.org was cached in the local repository, resolution will not be reattempted until the update interval of safehaus-repository has elapsed or updates are forced. Original error: Could not transfer metadata org.springframework.osgi:asm.osgi:2.2.3-SNAPSHOT/maven-metadata.xml from/to safehaus-repository (http://m2.safehaus.org): ConnectException
13-9-28 上午01时09分57秒: [WARN] Failure to transfer org.springframework.osgi:aopalliance.osgi:1.0-SNAPSHOT/maven-metadata.xml from http://m2.safehaus.org was cached in the local repository, resolution will not be reattempted until the update interval of safehaus-repository has elapsed or updates are forced. Original error: Could not transfer metadata org.springframework.osgi:aopalliance.osgi:1.0-SNAPSHOT/maven-metadata.xml from/to safehaus-repository (http://m2.safehaus.org): ConnectException
13-9-28 上午01时09分58秒: [WARN] Failure to transfer org.springframework.osgi:log4j.osgi:1.2.15-SNAPSHOT/maven-metadata.xml from http://m2.safehaus.org was cached in the local repository, resolution will not be reattempted until the update interval of safehaus-repository has elapsed or updates are forced. Original error: Could not transfer metadata org.springframework.osgi:log4j.osgi:1.2.15-SNAPSHOT/maven-metadata.xml from/to safehaus-repository (http://m2.safehaus.org): ConnectException
13-9-28 上午01时09分58秒: Build errors for osgi; org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project osgi: Could not resolve dependencies for project com.hrbeu.app:osgi:bundle:0.0.1-SNAPSHOT: Failed to collect dependencies for [org.springframework:spring-core:jar:2.5.1 (compile), org.springframework:spring-context:jar:2.5.1 (compile), org.springframework:spring-beans:jar:2.5.1 (compile), org.slf4j:jcl104-over-slf4j:jar:1.4.3 (compile), org.slf4j:slf4j-api:jar:1.4.3 (compile), org.slf4j:slf4j-log4j12:jar:1.4.3 (compile), org.osgi:org.osgi.core:jar:4.0 (compile), org.springframework.osgi:junit.osgi:jar:3.8.2-SNAPSHOT (test), org.springframework:spring-test:jar:2.5.1 (test), org.springframework.osgi:spring-osgi-test:jar:1.0.2 (test), org.springframework.osgi:spring-osgi-annotation:jar:1.0.2 (test), org.springframework.osgi:aopalliance.osgi:jar:1.0-SNAPSHOT (test), org.eclipse.osgi:org.eclipse.osgi:jar:3.2.2 (test), org.springframework.osgi:log4j.osgi:jar:1.2.15-SNAPSHOT (test)]
13-9-28 上午01时18分53秒: Refreshing [/osgi/pom.xml]


成功构建

参考:http://marshal.easymorse.com/archives/730

在构建后需要修改pom.xml。为本地搭建的maven私服。

原始的为下:

<pluginRepositories> 
    <pluginRepository> 
        <id>maven-repo</id> 
        <name>maven repo</name> 
        <url>http://repo1.maven.org/maven2/ 
        </url> 
    </pluginRepository> 
    <pluginRepository> 
        <id>agilejava</id> 
        <url>http://agilejava.com/maven/</url> 
    </pluginRepository> 
</pluginRepositories> 
<repositories> 
    <repository> 
        <id>eclipse-repository</id> 
        <name>Eclipse Repository</name> 
        <url>http://repo1.maven.org/eclipse/ 
        </url> 
    </repository> 
    <repository> 
        <id>safehaus-repository</id> 
        <name>Safehaus Repository</name> 
        <url>http://m2.safehaus.org</url> 
    </repository> 
    <repository> 
        <id>spring-ext</id> 
        <name>Spring External Dependencies Repository</name> 
        <url> 
http://springframework.svn.sourceforge.net/svnroot/springframework/repos/repo-ext/ 
        </url> 
    </repository> 
    <repository> 
        <id>spring-release</id> 
        <name>Spring Portfolio Release Repository</name> 
        <url> http://s3.amazonaws.com/maven.springframework.org/release</url>
    </repository> 
    <repository> 
        <id>spring-external</id> 
        <name>Spring Portfolio Release Repository</name> 
        <url> http://s3.amazonaws.com/maven.springframework.org/external
        </url> 
    </repository> 
    <repository> 
        <id>spring-milestone</id> 
        <name>Spring Portfolio Milestone Repository</name> 
        <url> http://s3.amazonaws.com/maven.springframework.org/milestone
        </url> 
    </repository> 
    <repository> 
        <id>i21-s3-osgi-repo</id> 
        <name>i21 osgi artifacts repo</name> 
        <snapshots> 
            <enabled>true</enabled> 
        </snapshots> 
        <url> http://s3.amazonaws.com/maven.springframework.org/osgi</url>
    </repository> 
</repositories>


修改为:

<repositories>
<repository>
<id>nexus</id>
<name>local private nexus</name>
<url>http://l27.0.0.1:8081/nexus/content/groups/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>nexus-snapshots</id>
<name>local private nexus</name>
<url>http://l27.0.0.1:8081/nexus/content/groups/public-snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>nexus</id>
<name>local private nexus</name>
<url>http://l27.0.0.1:8081/nexus/content/groups/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>nexus-snapshots</id>
<name>local private nexus</name>
<url>http://l27.0.0.1:8081/nexus/content/groups/public-snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>

234433_uG3m_192871.png

234435_XD18_192871.png

构建成功运行结果:


转载于:https://my.oschina.net/hrbeu05/blog/261908

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值