maven私库nexus3安装及使用

一、试验环境

1、操作系统:Windows 10
2、nexus版本:nexus-3.0.1-01-win64

二、安装

1、下载地址:http://www.sonatype.com/download-oss-sonatype
maven私库nexus3安装及使用_第1张图片
2、我们下载nexus-3.0.1-01-win64.exe后双击安装即可,安装完成后默认开放8081端口。

三、使用

安装成功后有两个默认账号admin、anonymous,其中admin具有全部权限默认密码admin123;anonymous作为匿名用户,只具有查看权限。
maven私库nexus3安装及使用_第2张图片
maven私库nexus3安装及使用_第3张图片
maven私库nexus3安装及使用_第4张图片

pepositories说明

maven-central:maven中央库,默认从https://repo1.maven.org/maven2/拉取jar
maven-releases:私库发行版jar
maven-snapshots:私库快照(调试版本)jar
maven-public:仓库分组,把上面三个仓库组合在一起对外提供服务,在本地maven基础配置settings.xml中使用。

maven私库nexus3安装及使用_第5张图片
maven私库nexus3安装及使用_第6张图片

本地maven库配置settings.xml

<settings>

  <pluginGroups>
    <pluginGroup>org.sonatype.pluginspluginGroup>
  pluginGroups>

 <servers>
    <server>
      <id>nexusid>
      <username>adminusername>
      <password>admin123password>
    server>
  servers>

<mirrors>
    <mirror>
      <id>nexusid>
      <mirrorOf>*mirrorOf>
      <url>http://localhost:8081/repository/maven-public/url>
    mirror>
    <mirror>  
      <id>repo2id>  
      <mirrorOf>centralmirrorOf>  
      <name>Human Readable Name for this Mirror.name>  
      <url>http://repo2.maven.org/maven2/url>  
    mirror>

  mirrors>

<profiles>
<profile>
      <id>nexusid>
      <repositories>
        <repository>
          <id>centralid>
          <url>http://centralurl>
          <releases><enabled>trueenabled>releases>
          <snapshots><enabled>trueenabled>snapshots>
        repository>
      repositories>
     <pluginRepositories>
        <pluginRepository>
          <id>centralid>
          <url>http://centralurl>
          <releases><enabled>trueenabled>releases>
          <snapshots><enabled>trueenabled>snapshots>
        pluginRepository>
      pluginRepositories>
    profile>

  profiles>
  <activeProfiles>
    <activeProfile>nexusactiveProfile>
  activeProfiles>
settings>

工程配置pox.xml

<distributionManagement>
  <repository>
      <id>nexusid>
      <name>Releasesname>
      <url>http://localhost:8081/repository/maven-releasesurl>
    repository>
    <snapshotRepository>
      <id>nexusid>
      <name>Snapshotname>
      <url>http://localhost:8081/repository/maven-snapshotsurl>
    snapshotRepository>
  distributionManagement>
<build>
    <defaultGoal>compiledefaultGoal>
    <finalName>pagefinalName>
    <plugins>
        <plugin> 
            <groupId>org.apache.maven.pluginsgroupId> 
            <artifactId>maven-surefire-pluginartifactId>  
            <configuration>  
                <skip>trueskip>  
            configuration> 
        plugin>
        <plugin>
                <groupId>org.apache.maven.pluginsgroupId>
                <artifactId>maven-compiler-pluginartifactId>
                <version>3.3version>
                <configuration>
                    <source>1.8source>
                    <target>1.8target>
                configuration>
            plugin>
    plugins>
  build>

编译到maven私库

deploy -e
项目右单击->Run As->Maven build..
进入如下界面
maven私库nexus3安装及使用_第7张图片

快照编译:pom.xml中版本设置

<version>0.0.1-SNAPSHOTversion>

编译后在nexus中看到如下图结果,快照已经编译到nexus中Components-> maven-snapshots。
maven私库nexus3安装及使用_第8张图片

发行版编译:pom.xml中版本设置

<version>0.0.1-RELEASEversion>

编译后在nexus中看到如下图结果,发行版已经编译到nexus中Components->maven-releases。
maven私库nexus3安装及使用_第9张图片

你可能感兴趣的:(maven,nexus3)