Nexus版本是2.14.2-01-bundle,支持jdk1.7 。
部署在ip为192.168.2.102的虚拟机上,目录路径在/apps/svr/Nexus/nexus-2.14.2-01/中。

Nexus管理

访问路径是http://192.168.2.102:8081/nexus
管理账号:admin/admin123
所有发布到maven私库上的目录都可以通过http://192.168.2.102:8081/nexus/content/groups/public/ 访问得到,但是在Nexus上分了三个目录,分别存储不同的内容:
3rd party:第三方jar包存放目录。
Releases:发布版本的目录。
Snapshots:开发版本的目录。

登录Nexus首先要将目录的Deployment Policy属性设置为Allow Redoploy,这个设置是让项目可以重复部署。

Nexus还提供了用户管理的功能,可以在左侧菜单依次打开Security->Users,打开用户管理界面。

配置认证

在maven目录conf中的setting.xml中设置添加元素

    <servers>
      <server>
      <id>releases</id> <!-- id要与Nexus中的id对应上 -->
      <username>saleson</username>
      <password>******</password>
    </server>
    <server>
      <id>snapshots</id> <!-- id要与Nexus中的id对应上 -->
      <username>saleson</username>
      <password>******</password>
    </server>
    <server>
      <id>thirdparty</id> <!-- id要与Nexus中的id对应上 -->
      <username>saleson</username>
      <password>******</password>
    </server>
  </servers>

在项目的pom.xml文件中配置:

<!-- 仓库地址 -->
    <repositories>
        <repository>
            <id>public</id>
            <name>Team Nexus Repository</name>
            <url>http://192.168.2.102:8081/nexus/content/groups/public</url>
        </repository>
    </repositories>

    <!-- 插件地址 -->
    <pluginRepositories>
        <pluginRepository>
            <id>public</id>
            <name>Team Nexus Repository</name>
            <url>http://192.168.2.102:8081/nexus/content/groups/public</url>
        </pluginRepository>
    </pluginRepositories>

    <distributionManagement>
        <repository>
            <id>releases</id>
            <url>http://192.168.2.102:8081/nexus/content/repositories/releases/</url>
        </repository>
        <snapshotRepository>
            <id>snapshots</id>
            <url>http://192.168.2.102:8081/nexus/content/repositories/snapshots/</url>
        </snapshotRepository>
    </distributionManagement>

在项目根目录下运行mvn deploy -e就可以将jar包提交到Nexus服务器上了。

也可以在Eclipse 中配置一个maven build,Debug->Debug Configurations->Maven Build->New ,选择要提交的项目,在Goals那行输入:deploy -e,然后点击Debug,就可以将jar文件提交到Nexus服务器上了。

关于发布jar包到Snaphots和Releases目录

这两个目录是根据提交时,项目的version有关的,根据version后缀,如果是以-SNAPSHOT结尾的,会发布到Snaphots目录,否则发布到Releases目录。

<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.single</groupId>
    <artifactId>zzh-root</artifactId>
    <version>0.0.1-SNAPSHOT</version> <!-- 对应Snapshots Policy,发布到Snapshots目录。 -->
    <!-- <version>0.0.1</version> --> <!-- 对应Releases Policy,发布到Releases目录。 -->
    <packaging>pom</packaging>
</project>

maven父项目的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.single</groupId>
    <artifactId>***-parent</artifactId>
    <version>0.0.1-SNAPSHOT</version> <!-- 对应Snapshots Policy,发布到Snapshots目录。 -->
    <!-- <version>0.0.1</version> --> <!-- 对应Releases Policy,发布到Releases目录。 -->
    <packaging>pom</packaging>

    <!-- 仓库地址 -->
    <repositories>
        <repository>
            <id>public</id>
            <name>Team Nexus Repository</name>
            <url>http://192.168.2.102:8081/nexus/content/groups/public</url>
        </repository>
    </repositories>

    <!-- 插件地址 -->
    <pluginRepositories>
        <pluginRepository>
            <id>public</id>
            <name>Team Nexus Repository</name>
            <url>http://192.168.2.102:8081/nexus/content/groups/public</url>
        </pluginRepository>
    </pluginRepositories>

    <distributionManagement>
        <repository>
            <id>releases</id>
            <url>http://192.168.2.102:8081/nexus/content/repositories/releases/</url>
        </repository>
        <snapshotRepository>
            <id>snapshots</id>
            <url>http://192.168.2.102:8081/nexus/content/repositories/snapshots/</url>
        </snapshotRepository>
    </distributionManagement>

    <properties>
        <spring.version>3.2.13.RELEASE</spring.version>
        <aspectjweaver.version>1.8.9</aspectjweaver.version>
        <cglib-nodep.version>2.2.2</cglib-nodep.version>
        <cglib.version>2.2.2</cglib.version>
        <javax.persistence-api.version>1.0</javax.persistence-api.version>
        <druid.version>1.0.27</druid.version>
        <mysql-connector-java.version>6.0.5</mysql-connector-java.version>
        <mybatis.version>3.4.1</mybatis.version>
        <mybatis-spring.version>1.3.0</mybatis-spring.version>
        <tk.mapper.version>3.3.9</tk.mapper.version>
        <pagehelper.version>4.2.1</pagehelper.version>
        <quartz.version>2.2.3</quartz.version>
        <hibernate-validator.version>5.3.4.Final</hibernate-validator.version>
        <dubbo.version>2.8.4</dubbo.version>
        <zookeeper.version>3.4.9</zookeeper.version>
        <spring-data-redis.version>1.7.5.RELEASE</spring-data-redis.version>
        <jedis.version>2.9.0</jedis.version>
        <fastjson.version>1.2.22</fastjson.version>
        <jackson.version>2.8.5</jackson.version>
        <jackson-mapper-asl.version>1.9.13</jackson-mapper-asl.version>
        <caucho.hessian.version>4.0.38</caucho.hessian.version>
        <httpclient.version>4.5.2</httpclient.version>
        <commons-lang3.version>3.5</commons-lang3.version>
        <commons-io.version>2.5</commons-io.version>
        <commons-collections.version>3.2.2</commons-collections.version>
        <commons-beanutils.version>1.9.3</commons-beanutils.version>
        <commons-codec.version>1.10</commons-codec.version>
        <commons-pool.version>1.6</commons-pool.version>
        <commons-math3.version>3.6.1</commons-math3.version>
        <commons-fileupload.version>1.3.2</commons-fileupload.version>
        <dozer.version>5.5.1</dozer.version>
        <guava.version>20.0</guava.version>
        <joda-time.version>2.9.6</joda-time.version>
        <prettytime.version>4.0.1.Final</prettytime.version>
        <log4j.version>1.2.7</log4j.version>
        <slf4j.version>1.7.22</slf4j.version>
        <logback.version>1.1.8</logback.version>
    </properties>
    <dependencyManagement>
        <dependencies>

            <!-- j2ee web spec -->
            <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>javax.servlet-api</artifactId>
                <version>3.1.0</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>servlet-api</artifactId>
                <version>2.5</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>jstl</artifactId>
                <version>1.2</version>
            </dependency>
            <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>jsp-api</artifactId>
                <version>2.0</version>
                <exclusions>
                    <exclusion>
                        <groupId>javax.servlet</groupId>
                        <artifactId>javax.servlet-api</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <!-- WEB end -->
            <!-- Spring Framework -->
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-context</artifactId>
                <version>${spring.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-core</artifactId>
                <version>${spring.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-beans</artifactId>
                <version>${spring.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-web</artifactId>
                <version>${spring.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-webmvc</artifactId>
                <version>${spring.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-jdbc</artifactId>
                <version>${spring.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-tx</artifactId>
                <version>${spring.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-context-support</artifactId>
                <version>${spring.version}</version>
            </dependency>

            <!-- aop -->
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-aop</artifactId>
                <version>${spring.version}</version>
            </dependency>
            <dependency>
                <groupId>org.aspectj</groupId>
                <artifactId>aspectjweaver</artifactId>
                <version>${aspectjweaver.version}</version>
            </dependency>
            <dependency>
                <groupId>cglib</groupId>
                <artifactId>cglib-nodep</artifactId>
                <version>${cglib-nodep.version}</version>
            </dependency>
            <dependency>
                <groupId>cglib</groupId>
                <artifactId>cglib</artifactId>
                <version>${cglib.version}</version>
            </dependency>


            <!-- spring test -->
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-test</artifactId>
                <version>${spring.version}</version>
            </dependency>

            <!-- persistence api -->
            <dependency>
                <groupId>javax.persistence</groupId>
                <artifactId>persistence-api</artifactId>
                <version>${javax.persistence-api.version}</version>
            </dependency>

            <!-- jdbc -->
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>druid</artifactId>
                <version>${druid.version}</version>
            </dependency>
            <dependency>
                <groupId>mysql</groupId>
                <artifactId>mysql-connector-java</artifactId>
                <version>${mysql-connector-java.version}</version>
            </dependency>


            <!-- mybatis -->
            <dependency>
                <groupId>org.mybatis</groupId>
                <artifactId>mybatis</artifactId>
                <version>${mybatis.version}</version>
            </dependency>
            <dependency>
                <groupId>org.mybatis</groupId>
                <artifactId>mybatis-spring</artifactId>
                <version>${mybatis-spring.version}</version>
            </dependency>
            <dependency>
                <groupId>tk.mybatis</groupId>
                <artifactId>mapper</artifactId>
                <version>${tk.mapper.version}</version>
            </dependency>
            <dependency>
                <groupId>com.github.pagehelper</groupId>
                <artifactId>pagehelper</artifactId>
                <version>${pagehelper.version}</version>
            </dependency>


            <!-- json -->
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>fastjson</artifactId>
                <version>${fastjson.version}</version>
            </dependency>
            <dependency>
                <groupId>com.fasterxml.jackson.core</groupId>
                <artifactId>jackson-databind</artifactId>
                <version>${jackson.version}</version>
            </dependency>
            <dependency>
                <groupId>com.fasterxml.jackson.core</groupId>
                <artifactId>jackson-core</artifactId>
                <version>${jackson.version}</version>
            </dependency>
            <dependency>
                <groupId>org.codehaus.jackson</groupId>
                <artifactId>jackson-mapper-asl</artifactId>
                <version>${jackson-mapper-asl.version}</version>
            </dependency>



            <!-- 定时 -->
            <dependency>
                <groupId>org.quartz-scheduler</groupId>
                <artifactId>quartz</artifactId>
                <version>${quartz.version}</version>
            </dependency>

            <!-- JSR303 Bean Validator -->
            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-validator</artifactId>
                <version>${hibernate-validator.version}</version>
            </dependency>


            <!-- Dubbo eXtensions -->
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>dubbo</artifactId>
                <version>${dubbo.version}</version>
                <exclusions>
                    <exclusion>
                        <artifactId>spring</artifactId>
                        <groupId>org.springframework</groupId>
                    </exclusion>
                </exclusions>
            </dependency>

            <dependency>
                <groupId>org.apache.zookeeper</groupId>
                <artifactId>zookeeper</artifactId>
                <version>${zookeeper.version}</version>
            </dependency>
            <dependency>
                <groupId>com.github.sgroschupf</groupId>
                <artifactId>zkclient</artifactId>
                <version>0.1</version>
            </dependency>


            <!-- redis -->
            <dependency>
                <groupId>org.springframework.data</groupId>
                <artifactId>spring-data-redis</artifactId>
                <version>${spring-data-redis.version}</version>
            </dependency>
            <dependency>
                <groupId>redis.clients</groupId>
                <artifactId>jedis</artifactId>
                <version>${jedis.version}</version>
            </dependency>

            <!-- hessian -->
            <dependency>
                <groupId>com.caucho</groupId>
                <artifactId>hessian</artifactId>
                <version>${caucho.hessian.version}</version>
            </dependency>



            <!-- http client -->
            <dependency>
                <groupId>org.apache.httpcomponents</groupId>
                <artifactId>httpclient</artifactId>
                <version>${httpclient.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.httpcomponents</groupId>
                <artifactId>httpclient-cache</artifactId>
                <version>${httpclient.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.httpcomponents</groupId>
                <artifactId>httpmime</artifactId>
                <version>${httpclient.version}</version>
            </dependency>

            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-lang3</artifactId>
                <version>${commons-lang3.version}</version>
            </dependency>
            <dependency>
                <groupId>commons-io</groupId>
                <artifactId>commons-io</artifactId>
                <version>${commons-io.version}</version>
            </dependency>
            <dependency>
                <groupId>commons-collections</groupId>
                <artifactId>commons-collections</artifactId>
                <version>${commons-collections.version}</version>
            </dependency>
            <dependency>
                <groupId>commons-codec</groupId>
                <artifactId>commons-codec</artifactId>
                <version>${commons-codec.version}</version>
            </dependency>
            <dependency>
                <groupId>commons-beanutils</groupId>
                <artifactId>commons-beanutils</artifactId>
                <version>${commons-beanutils.version}</version>
                <exclusions>
                    <exclusion>
                        <groupId>commons-logging</groupId>
                        <artifactId>commons-logging</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>commons-pool</groupId>
                <artifactId>commons-pool</artifactId>
                <version>${commons-pool.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-math3</artifactId>
                <version>${commons-math3.version}</version>
            </dependency>
            <dependency>
                <groupId>commons-fileupload</groupId>
                <artifactId>commons-fileupload</artifactId>
                <version>${commons-fileupload.version}</version>
            </dependency>





            <!-- pojo copy/java bean property copy -->
            <dependency>
                <groupId>net.sf.dozer</groupId>
                <artifactId>dozer</artifactId>
                <version>${dozer.version}</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.slf4j</groupId>
                        <artifactId>slf4j-log4j12</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>net.sf.dozer</groupId>
                <artifactId>dozer-spring</artifactId>
                <version>${dozer.version}</version>
            </dependency>

            <!-- google java library -->
            <dependency>
                <groupId>com.google.guava</groupId>
                <artifactId>guava</artifactId>
                <version>${guava.version}</version>
            </dependency>

            <dependency>
                <groupId>joda-time</groupId>
                <artifactId>joda-time</artifactId>
                <version>${joda-time.version}</version>
            </dependency>
            <dependency>
                <groupId>org.ocpsoft.prettytime</groupId>
                <artifactId>prettytime</artifactId>
                <version>${prettytime.version}</version>
            </dependency>



            <!-- LOGGING begin -->
            <!-- log4j -->
            <dependency>
                <groupId>log4j</groupId>
                <artifactId>log4j</artifactId>
                <version>${log4j.version}</version>
                <scope>provided</scope>
            </dependency>


            <!-- slf4j -->
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
                <version>${slf4j.version}</version>
            </dependency>

            <!-- logback -->
            <dependency>
                <groupId>ch.qos.logback</groupId>
                <artifactId>logback-classic</artifactId>
                <version>${logback.version}</version>
            </dependency>
            <dependency>
                <groupId>ch.qos.logback</groupId>
                <artifactId>logback-core</artifactId>
                <version>${logback.version}</version>
                <type>jar</type>
            </dependency>
            <dependency>
                <groupId>org.logback-extensions</groupId>
                <artifactId>logback-ext-spring</artifactId>
                <version>0.1.4</version>
            </dependency>

            <!-- 代码直接调用log4j会被桥接到slf4j -->
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>log4j-over-slf4j</artifactId>
                <version>${slf4j.version}</version>
            </dependency>

            <!-- 代码直接调用commons-logging会被桥接到slf4j -->
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>jcl-over-slf4j</artifactId>
                <version>${slf4j.version}</version>
            </dependency>

            <!-- 代码直接调用java.util.logging会被桥接到slf4j -->
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>jul-to-slf4j</artifactId>
                <version>${slf4j.version}</version>
            </dependency>

            <!-- log4jdbc -->
            <dependency>
                <groupId>com.googlecode.log4jdbc</groupId>
                <artifactId>log4jdbc</artifactId>
                <version>1.2</version>
                <scope>runtime</scope>
            </dependency>
            <!-- LOGGING end -->

            <!-- 图片处理工具 -->
            <dependency>
                <groupId>net.coobird</groupId>
                <artifactId>thumbnailator</artifactId>
                <version>0.4.8</version>
            </dependency>
        </dependencies>
    </dependencyManagement>


    <profiles>
        <profile>
            <!-- 生产环境 -->
            <id>production</id>
            <properties>
                <profiles.active>production</profiles.active>
            </properties>
            <!-- <activation> <activeByDefault>true</activeByDefault> </activation> -->
        </profile>
        <profile>
            <!-- 预发布环境 -->
            <id>prerelease</id>
            <properties>
                <profiles.active>prerelease</profiles.active>
            </properties>
            <!-- <activation> <activeByDefault>true</activeByDefault> </activation> -->
        </profile>
        <profile>
            <!-- 本地开发环境 -->
            <id>dev</id>
            <properties>
                <profiles.active>dev</profiles.active>
            </properties>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
        </profile>
        <profile>
            <!-- 测试环境 -->
            <id>test</id>
            <properties>
                <profiles.active>test</profiles.active>
            </properties>
        </profile>
    </profiles>
</project>

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐