nexus3.x搭建私服并配置本地maven发布和依赖

1. 下载安装 nexus-3.14.04

注意:nexus-3.14.04要求安装JDK1.8以上版本

1.1 下载

下载地址:点击下载

1.2 在Linux(ubuntu-16.04.5_64bit)解压安装

# tar xf nexus-3.14.0-04-unix.tar.gz -C /usr/local/software/
# cd /usr/local/software/nexus-3.14.0-04

1.3 适当修改nexus-3.14.04参数

文件分别为nexus.rcnexus.vmoptions,笔者修改如下:

nexus.vmoptions文件:

-Xms512M
-Xmx512M
-XX:MaxDirectMemorySize=1G
-XX:+UnlockDiagnosticVMOptions
-XX:+UnsyncloadClass
-XX:+LogVMOutput
-XX:LogFile=../sonatype-work/nexus3/log/jvm.log
-XX:-OmitStackTraceInFastThrow
-Djava.net.preferIPv4Stack=true
-Dkaraf.home=.
-Dkaraf.base=.
-Dkaraf.etc=etc/karaf
-Djava.util.logging.config.file=etc/karaf/java.util.logging.properties
-Dkaraf.data=../sonatype-work/nexus3
-Djava.io.tmpdir=../sonatype-work/nexus3/tmp
-Dkaraf.startLocalConsole=false

nexus.rc文件:

run_as_user="root"

1.4 启动服务

# /usr/local/software/nexus-3.14.0-04/bin/nexus start

1.5 使用

浏览器访问http://192.168.100.167:8081,使用nexus默认用户名密码登陆admin/admin123,

1.5.1 创建管理用户

你可以配置一个管理用户:

nexus3.x搭建私服并配置本地maven发布和依赖_第1张图片
创建页面:
nexus3.x搭建私服并配置本地maven发布和依赖_第2张图片

1.5.2 创建仓库

登陆账号并创建自己的releasesnapshotproxy 仓库和仓库组:
nexus3.x搭建私服并配置本地maven发布和依赖_第3张图片

  • 创建release仓库,选择如下图中的maven2(hosted)
    nexus3.x搭建私服并配置本地maven发布和依赖_第4张图片
    创建:
    nexus3.x搭建私服并配置本地maven发布和依赖_第5张图片

  • 创建snapshot仓库,选择如下图中的maven2(hosted)
    nexus3.x搭建私服并配置本地maven发布和依赖_第6张图片
    创建:
    nexus3.x搭建私服并配置本地maven发布和依赖_第7张图片

  • 创建proxy仓库,选择如下图中的maven2(proxy),并配置阿里云为远端仓库:http://maven.aliyun.com/nexus/content/groups/public
    nexus3.x搭建私服并配置本地maven发布和依赖_第8张图片
    创建:
    nexus3.x搭建私服并配置本地maven发布和依赖_第9张图片

  • 创建仓库组用户使用者在mavensettings.xml中配置使用
    nexus3.x搭建私服并配置本地maven发布和依赖_第10张图片
    创建:
    nexus3.x搭建私服并配置本地maven发布和依赖_第11张图片

2. 使用nexus私服

2.1 配置本地Maven settings.xml



<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">

  <servers>
    <server>
      <id>releasesid>
      <username>jerryusername>
      <password>123456password>
    server>
    <server>
      <id>snapshotsid>
      <username>jerryusername>
      <password>123456password>
    server>
  servers>
  <mirrors>
    <mirror>
      <id>nexusid>
      <mirrorOf>centralmirrorOf>
      <name>*name>
      <url>http://192.168.100.167:8081/repository/java-public/url>
    mirror>
  mirrors>
settings>

2.2 配置项目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.0modelVersion>

  <groupId>com.zjwgroupId>
  <artifactId>my-utilartifactId>
  <version>2.1-SNAPSHOTversion>
  <distributionManagement>
    <repository>
      <id>releasesid>
      <url>http://192.168.100.167:8081/repository/java-release/url>
    repository>
    <snapshotRepository>
      <id>snapshotsid>
      <url>http://192.168.100.167:8081/repository/java-snapshot/url>
    snapshotRepository>
  distributionManagement>

  <dependencies>
    <dependency>
      <groupId>io.perfanagroupId>
      <artifactId>perfana-gatling-maven-pluginartifactId>
      <version>3.0.0version>
    dependency>
  dependencies>

  <build>
    <plugins>
      
      <plugin>
        <groupId>org.apache.maven.pluginsgroupId>
        <artifactId>maven-jar-pluginartifactId>
        <version>3.0.2version>
        <configuration>
          <excludes>
            <exclude>**/*.propertiesexclude>
          excludes>
        configuration>
      plugin>
      
      <plugin>
        <groupId>org.apache.maven.pluginsgroupId>
        <artifactId>maven-source-pluginartifactId>
        <version>3.0.1version>
        <configuration>
          <attach>trueattach>
        configuration>
        <executions>
          <execution>
            <phase>compilephase>
            <goals>
              <goal>jargoal>
            goals>
          execution>
        executions>
      plugin>
    plugins>
  build>
project>

你可能感兴趣的:(maven,settings.xml)