Maven私服搭建
1:启动nexus服务报错
搭建指南参考:
查看启动日志: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.0jvm 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插件
在线安装方式
1 打开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项目
参考:
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-SNAPSHOT13-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 1213-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): ConnectException13-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): ConnectException13-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): ConnectException13-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): ConnectException13-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): ConnectException13-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]
成功构建
参考:
在构建后需要修改pom.xml。为本地搭建的maven私服。
原始的为下:
maven-repo maven repo http://repo1.maven.org/maven2/ agilejava http://agilejava.com/maven/ eclipse-repository Eclipse Repository http://repo1.maven.org/eclipse/ safehaus-repository Safehaus Repository http://m2.safehaus.org spring-ext Spring External Dependencies Repository http://springframework.svn.sourceforge.net/svnroot/springframework/repos/repo-ext/ spring-release Spring Portfolio Release Repository http://s3.amazonaws.com/maven.springframework.org/release spring-external Spring Portfolio Release Repository http://s3.amazonaws.com/maven.springframework.org/external spring-milestone Spring Portfolio Milestone Repository http://s3.amazonaws.com/maven.springframework.org/milestone i21-s3-osgi-repo i21 osgi artifacts repo true http://s3.amazonaws.com/maven.springframework.org/osgi
修改为:
nexus local private nexus http://l27.0.0.1:8081/nexus/content/groups/public true false nexus-snapshots local private nexus http://l27.0.0.1:8081/nexus/content/groups/public-snapshots false true nexus local private nexus http://l27.0.0.1:8081/nexus/content/groups/public true false nexus-snapshots local private nexus http://l27.0.0.1:8081/nexus/content/groups/public-snapshots false true
构建成功运行结果: