TypechoJoeTheme

IT技术分享

统计

FreeBSD上搭建Nexus3 Java私有Maven仓库

2022-03-03
/
3 评论
/
5,437 阅读
/
正在检测是否收录...
03/03

一、安装 openjdk8

pkg install openjdk8

二、安装 nexus

wget https://www.sonatype.com/oss-thank-you-tar.gz

2.1 修改端口

vim etc/nexus-default.properties

2.2 修改运行用户

vim bin/nexus.rc

2.3 修改 jvm

vim bin/nexus.jvmoptions

2.4 启动

bin/nexus start (stop/restart...)

三、安装 nginx

pkg install nginx

3.1 配置 nginx

vim /usr/local/etc/nginx/nginx.conf
server {
       listen       80;
       server_name [你的域名];

        charset utf-8;
        access_log  logs/nexus_access.log main;
        include proxy.conf;

        location / {
            proxy_pass http://127.0.0.1:8081;
        }

        location ~ ^/(WEB-INF)/ {
            deny all;
        }

        location ~ \.(php|asp|aspx) {
            deny all;
        }
    }

其中proxy.conf的内容为

proxy_redirect          off;
proxy_set_header        Host            $host;
proxy_set_header        X-Real-IP       $remote_addr;
proxy_set_header        RealIP          $remote_addr;
proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;

client_max_body_size    100m;
proxy_connect_timeout   3s;
proxy_send_timeout      1m;
proxy_read_timeout      1m;
proxy_temp_file_write_size 1024m;
proxy_buffer_size         32k;
proxy_buffers             4 32k;
proxy_busy_buffers_size 64k;
proxy_ignore_client_abort on;
proxy_next_upstream error timeout invalid_header http_503;

启动 nginx

service nginx start

四、配置 nexus

访问 nexus, 登录 admin, 密码在sonatype-work中

4.1 禁用 maven 中心同步

4.2 配置角色

只开放

nx-repository-view-maven2-maven-releases-*
nx-repository-view-maven2-maven-snapshots-*

Roles 包含 nx-anonymous

4.3 增加uploader 用户

绑定 role,同时加上nx-anonymous

五、gradle 配置

5.1 上传

增加maven发布插件

plugins {
    id 'maven-publish'
}

5.2 拉包

配置好仓库

repositories {
    maven {
        url 'https://maven.aliyun.com/repository/public/'
    }
    mavenLocal()
    mavenCentral()
    maven {
        url 'http://[你的域名]/repository/maven-releases/'
        credentials {
            username = '[您的用户名]'
            password = '[您的密码]'
        }
    }
    maven {
        url 'http://[你的域名]/repository/maven-snapshots/'
        credentials {
            username = '[您的用户名]'
            password = '[您的密码]'
        }
    }
}
FreeBSDNexus3JavaMaven
朗读
赞 · 0
版权属于:

IT技术分享

本文链接:

https://idunso.com/archives/18/(转载时请注明本文出处及文章链接)