Create local maven repository

后端 未结 3 1338
Happy的楠姐
Happy的楠姐 2020-12-04 16:34

I want to create local maven repository. I did the following steps:

  1. Installed maven plugin in eclipse
  2. Created one folder localrepository in apache s
3条回答
  •  无人及你
    2020-12-04 17:00

    Yes you can! For a simple repository that only publish/retrieve artifacts, you can use nginx.

    1. Make sure nginx has http dav module enabled, it should, but nonetheless verify it.

    2. Configure nginx http dav module:

      In Windows: d:\servers\nginx\nginx.conf

      location / {
          # maven repository
          dav_methods  PUT DELETE MKCOL COPY MOVE;
          create_full_put_path  on;
          dav_access  user:rw group:rw all:r;
      }
      

      In Linux (Ubuntu): /etc/nginx/sites-available/default

      location / {
              # First attempt to serve request as file, then
              # as directory, then fall back to displaying a 404.
              # try_files $uri $uri/ =404;  # IMPORTANT comment this
              dav_methods  PUT DELETE MKCOL COPY MOVE;
              create_full_put_path  on;
              dav_access  user:rw group:rw all:r;
      }
      

      Don't forget to give permissions to the directory where the repo will be located:

      sudo chmod +777 /var/www/html/repository

    3. In your project's pom.xml add the respective configuration:

      Retrieve artifacts:

      
          
              repository
              http:///repository
          
      
      

      Publish artifacts:

      
          
              
                  org.apache.maven.wagon
                  wagon-http
                  3.2.0
              
          
      
      
          
              repository
              http:///repository
          
      
      
    4. To publish artifacts use mvn deploy. To retrieve artifacts, maven will do it automatically.

    And there you have it a simple maven repo.

提交回复
热议问题