[bigdata-097]搭建maven私服 nexus
发布时间:2020-12-14 03:08:44 所属栏目:大数据 来源:网络整理
导读:1. nexus官网 http://www.sonatype.org/nexus/ 2. 下载 https://www.sonatype.com/download-oss-sonatype 选择2.x版本 http://www.sonatype.org/downloads/nexus-latest-bundle.tar.gz 3.nexus 2.x的文档 http://books.sonatype.com/nexus-book/reference/in
1. nexus官网
http://www.sonatype.org/nexus/ 2. 下载 https://www.sonatype.com/download-oss-sonatype 选择2.x版本 http://www.sonatype.org/downloads/nexus-latest-bundle.tar.gz 3.nexus 2.x的文档 http://books.sonatype.com/nexus-book/reference/index.html 4. 安装 将nexus-latest-bundle.tar.gz解压缩,放到~/usr/nexus目录 5. 运行 5.1 启动命令: ./bin/nexus start 5.2 登录http://localhost:8081/nexus 默认帐号和密码 ?admin:admin123 5.3 配置 选择central,将Download Remote Indexes设置为true,下载索引。 5.4 在central上点击右键,选择重建索引 5.5 也可以在这里新建prxoy的repository,以及host repository,具体方式参考各种文档 6. 然后在项目里就可以引用这个repository了,也就是pom里配置,或者,在~/.m2/setting.xml里配置,这样所有的项目就优先使用本地nexus的repository 7. 一个完整的使用本地nexus的pom.xml例子 ---------------------- <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ? xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> ? <modelVersion>4.0.0</modelVersion> ? <groupId>com.tanzhi.demo</groupId> ? <artifactId>mysqljdbc</artifactId> ? <version>0.0.1-SNAPSHOT</version> ? <name>mysqljdbc</name> ? <url>http://maven.apache.org</url> ? <properties> ? ? <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> ? </properties> ?? ? <repositories> ? ? <repository> ? ? ? <id>my-nexus-central</id> ? ? ? <name>my local nexus</name> ? ? ? <url>http://localhost:8081/nexus/content/repositories/central/</url> ? ? ? <releases> ? ? ? ? <enabled>true</enabled> ? ? ? ? <updatePolicy>never</updatePolicy> ? ? ? </releases> ? ? ? ? </repository> ? </repositories> ? <dependencies> ? ? <dependency> ? ? ? <groupId>junit</groupId> ? ? ? <artifactId>junit</artifactId> ? ? ? <version>3.8.1</version> ? ? ? <scope>test</scope> ? ? </dependency> ? ? <dependency> ? ? <groupId>mysql</groupId> ? ? <artifactId>mysql-connector-java</artifactId> ? ? <version>5.1.27</version> ? ? </dependency> ? </dependencies> ?? ? <build> ? <plugins> ? <plugin> ? <groupId>org.apache.maven.plugins</groupId> ? <artifactId>maven-assembly-plugin</artifactId> ? <version>2.3</version> ? <configuration> ? ? ? ? ? ? ? ? ? ? <appendAssemblyId>false</appendAssemblyId> ? ? ? ? ? ? ? ? ? ? <descriptorRefs> ? ? ? ? ? ? ? ? ? ? ? ? <descriptorRef>jar-with-dependencies</descriptorRef> ? ? ? ? ? ? ? ? ? ? </descriptorRefs> ? ? ? ? ? ? ? ? ? ? <archive> ? ? ? ? ? ? ? ? ? ? ? ? <manifest> ? ? ? ? ? ? ? ? ? ? ? ? ? ? <mainClass>com.ttz.demo.mysqljdbc.App</mainClass> ? ? ? ? ? ? ? ? ? ? ? ? </manifest> ? ? ? ? ? ? ? ? ? ? </archive> ? ? ? ? ? ? ? ? </configuration> ? ? ? ? ? ? ? ? <executions> ? ? ? ? ? ? ? ? ? ? <execution> ? ? ? ? ? ? ? ? ? ? ? ? <id>make-assembly</id> ? ? ? ? ? ? ? ? ? ? ? ? <phase>package</phase> ? ? ? ? ? ? ? ? ? ? ? ? <goals> ? ? ? ? ? ? ? ? ? ? ? ? ? ? <goal>assembly</goal> ? ? ? ? ? ? ? ? ? ? ? ? </goals> ? ? ? ? ? ? ? ? ? ? </execution> ? ? ? ? ? ? ? ? </executions> ? </plugin> ? </plugins> ? </build> </project>---------------------- 8. 注意事项 8.1 eclipse在更新上经常出问题,莫名其妙地出错。因此,最好在maven项目下执行mvn clean package,此时maven会主动做更新,然后在eclipse里也就正常了。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |