Non-mvn project and build the project into mvn mvn PW

Non-mvn project and build the project into mvn mvn PW

 

Scratch. Background

  The company's system is the old system, there is no use mvn, but is now ready to use continuous integration (CI), is necessary to use mvn, so now you need to turn the old project mvn project and non-project is also bad mvn build and expand .

  Build your own mvn PW, because there are some projects in the central repository jar it is unable to download, so I need to build their own private servers warehouse on the company's servers, and to spread these jar on private servers.

 

II. Non-turn mvn project mvn project

 

  The most intuitive difference 1. Non-mvn and mvn project pom.xml of course, so now we need to create a pom file on their own projects.

  2. I am using a tool idea, I just right-pom file, add mvn project to the rest of the thing is the thing tools.

  3. Now you need to jar all previous projects in the pom file written inside, and there's water is quite deep, the first jar is more and more, followed by a lot of what you might not find, or rely version of the problem, anyway, this will take some time.

    When you find a part mvn jar wrapped in a central repository how can not find, you might want to realize that this jar package may have never had, so we need to use PW to upload your own jar file.

 

 

III. PW installation

  1. download the free version of Nexus: https://www.sonatype.com/download-oss-sonatype :

  

    Project selection according to their needs version 2 or version 3, after a successful download, install their own. After successful installation start you can see on the page the following information:

    

     The initial login account / password: admin / admin123, port 8080, which can all be configured in config own modification, there is not much to say.

 

 

IV. Configuration Item

 

  1. Modify the local repository mvn and mvn the settings.xml

 

  Find mvn install plug-ins you use, config in the installation path in the inside settings.xml file is modified:

   

<servers>
    <!-- server
     | Specifies the authentication information to use when connecting to a particular server, identified by
     | a unique name within the system (referred to by the 'id' attribute below).
     |
     | NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are
     |       used together.
     |
    <server>
      <id>deploymentRepo</id>
      <username>repouser</username>
      <password>repopwd</password>
    </server>
    -->
    <server>
        <id>central</id>
        <username>admin</username>
        <password>admin123</password>
    </server>
    <server>
        <id>thirdparty</id>
        <username>admin</username>
        <password>admin123</password>
    </server>

    <!-- Another sample, using keys to authenticate.
    <server>
      <id>siteServer</id>
      <privateKey>/path/to/private/key</privateKey>
      <passphrase>optional; leave empty if not used.</passphrase>
    </server>
    -->
  </servers>

   

<mirrors>
    <!-- mirror
     | Specifies a repository mirror site to use instead of a given repository. The repository that
     | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
     | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
     |
    <mirror>
      <id>mirrorId</id>
      <mirrorOf>repositoryId</mirrorOf>
      <name>Human Readable Name for this Mirror.</name>
      <url>http://my.repository.com/repo/path</url>
    </mirror>
    
     -->
     <mirror>
        <id>nexus-releases</id>
        <url>http://192.168.50.191:8081/nexus/content/groups/public/</url>
        <mirrorOf>*</mirrorOf>        
    </mirror>
    <mirror>
        <id>nexus-snapshots</id>
        <url>http://192.168.50.191:8081/nexus/content/groups/public//</url>
        <mirrorOf>*</mirrorOf>        
    </mirror>
  </mirrors>

  在pom文件里面添加:

  

    <repositories>
        <repository>
            <id>central</id>
            <name>Central</name>
            <url>http://192.168.50.191:8081/nexus/content/repositories/central/</url>
        </repository>
        <repository>
            <id>thirdparty</id>
            <name>3rd party</name>
            <url>http://192.168.50.191:8081/nexus/content/repositories/thirdparty/</url>
        </repository>
    </repositories>

 

 

五.上传jar包到mvn私服

 

  这里面有2种方式(命令和页面操作)

  1.页面操作

  

    这个就不用多说了,就是界面点点点

 

  2.命令上传

 

    在你的项目pom文件目录,cmd执行上传:

  

mvn deploy:deploy-file -DgroupId=com.fh -DartifactId=servlet-api -Dversion=1.0 -Dpackaging=jar -Dfile=E:\workspace\BPM\WebRoot\WEB-INF\lib\servlet-api.jar -Durl=http://192.168.50.191:8081/nexus/content/repositories/thirdparty/ -DrepositoryId=thirdparty

 

 

  mvn私服是公司里面必备的技能之一,可以多多学习下。

 

Guess you like

Origin www.cnblogs.com/zhaowei520/p/10975184.html