mavan开发要点总结(二)

2020-05-07  本文已影响0人  renmen2000

四、基于nexus搭建企业级内网私服

1、nexus安装

2、nexus中的各种仓库认识

如果文字无法描述清楚亲自安装nexus后浏览仓库实际下载打包发布相关包后即可理解

3、手工配置nexus仓库

4、改造公司项目配置使用私服
<profiles>
    <profile>
        <id>nexus</id>
        <!--依赖包下载配置走私服-->
        <repositories>
                <repository>
                    <id>nexus</id>
                    <name>Nexus </name>
                    <url>http://localhost:8081/nexus/content/groups/public</url>
                    <releases><enabled>true</enabled></releases>
                    <snapshots><enabled>true</enabled></snapshots>
                </repository>
        </repositories>
        <pluginRepositories>
                <!--插件下载配置走私服-->
                <pluginRepository>
                    <id>nexus</id>
                    <name>Nexus Plugin Repository</name>
                    <url>http://localhost:8081/nexus/content/groups/public</url>
                    <releases><enabled>true</enabled></releases>
                    <snapshots><enabled>true</enabled></snapshots>
                </pluginRepository>
        </pluginRepositories>
    </profile>
</profiles>
<!--激活的profile-->
<activeProfiles>
    <activeProfile>nexus</activeProfile>
</activeProfiles>

这样会强制将activeProfile里激活的profile对应的私服地址应用到每个项目中去

<mirrors>
    <mirror>
        <id>nexus</id>
        <mirrorOf>*</mirrorOf>
        <url>http://localhost:8081/nexus/content/groups/public</url>
    </mirror>
</mirros>
<profiles>
    <profile>
        <id>nexus</id>
        <!--依赖包下载配置走私服-->
        <repositories>
                <repository>
                    <id>nexus</id>
                    <name>Nexus </name>
                    <url>http://central</url>
                    <releases><enabled>true</enabled></releases>
                    <snapshots><enabled>true</enabled></snapshots>
                </repository>
        </repositories>
        <pluginRepositories>
                <!--插件下载配置走私服-->
                <pluginRepository>
                    <id>nexus</id>
                    <name>Nexus Plugin Repository</name>
                    <url>http://central</url>
                    <releases><enabled>true</enabled></releases>
                    <snapshots><enabled>true</enabled></snapshots>
                </pluginRepository>
        </pluginRepositories>
    </profile>
</profiles>

<!--激活的profile-->
<activeProfiles>
    <activeProfile>nexus</activeProfile>
</activeProfiles>
5、nexus权限管理机制
6、部署项目到私服
<distributionManagement>
    <!--releases版本发布仓库-->
    <repository>
        <id> nexus-releases</id>
        <name> Nexus Release Repository</name>
        <url>http://localhost:8081/nexus/content/repositories/releases/</url>
    </repository>
    <!--快照版本发布仓库-->
    <snapshotRepository>
        <id> nexus-snapshots</id>
        <name> Nexus Snapshot Repository</name>
        <url>http://localhost:8081/nexus/content/repositories/snapshots/</url>
    </snapshotRepository>
</distributionManagement>
<servers>
    <server>
        <id>nexus-releases</id>
        <username>deployment</username>
        <password>deployment123</password>
    </server>
    <server>
        <id>nexus-snapshots</id>
        <username>deployment</username>
        <password>deployment123</password>
    </server>
</servers>

说明:这里的id对应pom配置中的id,这里的用户名密码对应上边再nexus中设置的deployment用户的用户名和密码

mvn deploy:deploy-file -DgroupId=com.csource -DartifactId=fastdfs-client-java -Dversion=1.24 -Dpackaging=jar -Dfile=F:\DevelopmentKit\fastdfs_client_v1.24.jar -Durl=http://localhost:8081/repository/3rd-party/ -DrepositoryId=nexus-3rd-party 

即是手动上传如下jar包到私服

    <server>
        <id>nexus-3rd-party</id>
        <username>deployment</username>
        <password>deployment123</password>
    </server>

类似也可以用mvn instaill:install-file将jar包安装到本地仓库

上一篇 下一篇

猜你喜欢

热点阅读