如何在GitHub上创建自己的Maven仓库

第一阶段 :配置github

1、创建mvn-repo分支

    首先在你的github上创建一个maven-repo仓库,这个最后将作为实际上jar包发布的仓库

2、设置真实姓名

    在github的个人设置中,设置好自己的姓名 。这个环节很重要,若不设置姓名,会出现一些一些意想不到的错误,如:

[ERROR] Failed to execute goal com.github.github:site-maven-plugin:0.12:site (default) on project rfcore: Error creating commit: Invalid request.

[ERROR] For 'properties/name', nil is not a string.

[ERROR] For 'properties/name', nil is not a string. (422)

[ERROR] -> [Help 1]

第二阶段:配置部署jar到本地

1、 配置本地mvn服务

    设置本地maven的配置文件settings.xml,找到其中的servers 标签,加入如下 配置:

    github

    github登录名

     password>github登录密码

2、修改pom文件发布本地仓库

    在需要发布的项目中的pom文件里的 标签下加入以下插件:

    maven-deploy-plugin

    2.8.1

   

        internal.repo::default::file://${project.build.directory}/mvn-repo

   

然后运行 mvn clean deploy 命令,即可在对应项目中的target/mvn-repo目录下找到本地的jar

第三阶段:发布jar到远程github上

1、修改pom文件,在 properties 中添加下列属性

github

2、添加修改插件

    com.github.github

    site-maven-plugin

    0.12

    

        Maven artifacts for ${project.version}

        true

        ${project.build.directory}/mvn-repo

        refs/heads/master

        true

        

            **/*

        

        maven-repo

        你的用户名

    

    

        

            

                site

            

            deploy

        

    


再次执行 mvn clean deploy命令即可发布到github上了 。若出现如下错误请完成第一阶段第二步配置:

[ERROR] Failed to execute goal com.github.github:site-maven-plugin:0.12:site (default) on project rfcore: Error creating commit: Invalid request.

[ERROR] For 'properties/name', nil is not a string.

[ERROR] For 'properties/name', nil is not a string. (422)

[ERROR] -> [Help 1]

第四阶段:在项目中使用发布到github上的jar包

pom文件中添加github仓库

   

        maven-repo-master

        https://raw.github.com/你的用户名/maven-repo/master/

       

            true

            always

       

   

然后添加依赖即可 如我自己github-demo

    com.jun

    github-demo

    0.0.1-SNAPSHOT

配上我自己实现的结果展示,over!!!

你可能感兴趣的:(如何在GitHub上创建自己的Maven仓库)