mavenproxy

module
v0.0.0-...-96490c8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 11, 2023 License: MIT

README

一.插件描述

该模块借鉴了maven-manager, maven-manager使用java开发, 我在部署试用时 发现内存占用过大,且想整合多个中央参股功能, 所以用Go框架重新实现了一遍

  • 1.本人使用的Go版本为: 1.18.8
  • 2.配置文件读取来源于goframe默认的配置文件config.yaml,默认参数也可通过代码参数自行修改
  • 3.默认配置及参数字段具体释义见配置文件说明

二.插件必要的配置文件参数

1.配置文件说明

# 在gofarme框架默认读取的config.yml中添加自定义项maven
center:
    proxy:
      ###maven模块    #################################
      maven:
        cache: embedFs      #可以填写参数:本地embedFs/持久化nutsdb/本地Cos服务minioCos/七牛Cos服务qiniuCos/腾讯Cos服务tencentCos
        central:            # Mirrors中央仓库
          - https://repo1.maven.org/maven2
        mirror: # 镜像地址, 会先尝试在本地加载, 如果加载失败, 会尝试从镜像依次读取
          - https://maven.aliyun.com/nexus/content/repositories/public
          - https://repo1.maven.org/maven2
        repository: # 仓库设置
          - id: public # 仓库ID
            name: public repository # 仓库名字, 随意,唯一即可
            mode: 6 # 模式,默认为6,参数描述:0 无效 2 仅可写 4 仅可读 6 可读写
            auth: false # 是否鉴权, 默认鉴权,参数描述:true 鉴权 false不鉴权
            cache: true # 是否缓存镜像文件, 默认缓存,参数描述:true 缓存 false不缓存
          - id: private
            name: private repository
            mode: 4

2.启动参数自定义

  • 1.方法一(默认):读取程序内嵌指定的config.yaml中的配置文件
  • 2.方法二:存放配置config.yaml文件到启动时读取当前工作或执行目录下的configmanifest/config目录下
  • 3.方法三:通过命令行启动指定参数: ./main --gf.gcfg.file=config.yaml

三.拓展:定制开发module模块

1.指定gitee.com 为私有仓库

# 配置开启gomod
go env -w GO111MODULE="on"
# 配置GoMod私有仓库
go env -w GOPRIVATE="git@gitee.com"
# 配置不加密访问
go env -w GOINSECURE="gitee.com"
# 配置不使用代理
go env -w GONOPROXY="gitee.com"
# 配置不验证包
go env -w GONOSUMDB="gitee.com"

注意:经测试,go get 的tag 需在master分支方可下载最新代码 或: go get gitee.com/linngc/center.gf/contrib/module/cachebuffer@develop

四.部署后代理仓库服务用法

步骤一:修改maven配置修改

参数描述:
  • id 建议为配置文件下repository节点id值
  • username 建议为配置文件下authUser节点对应的用户名称
  • password 建议为配置文件下authUser节点对应的用户密码
<!-- 这里是需要上传的账号密码 -->
<servers>
    <server>
        <!--建议为配置文件下repository节点的名称 -->
        <id>public</id>
        <!--建议为配置文件下authUser节点对应的用户名称 -->
        <username>admin</username>
        <!--建议为配置文件下authUser节点对应的用户密码 -->
        <password>password</password>
    </server>
    <server>
        <id>private</id>
        <username>admin</username>
        <password>password</password>
    </server>
</servers>

步骤二:代理服务仓库修改

参数描述:
  • id 建议为配置文件下repository节点id值
  • name 建议为配置文件下repository节点name值
  • url 为当前服务ip:port/maven/public

<mirror>
    <id>public</id>
    <name>public repository</name>
    <url>http://localhost:10010/proxy/maven/public</url>
    <mirrorOf>central</mirrorOf>
</mirror>

步骤三:springboot工程项目中pom.xml文件修改


<distributionManagement>
    <repository>
        <id>public</id>
        <name>public repository</name>
        <url>http://localhost:10010/proxy/maven/public</url>
    </repository>
    <snapshotRepository>
        <id>private</id>
        <name>public repository</name>
        <url>http://localhost:10010/proxy/maven/public</url>
    </snapshotRepository>
</distributionManagement>

Directories

Path Synopsis
Package api @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @License
Package api @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @License
Package controller @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @License
Package controller @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @License
internal
business
Package business @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @License
Package business @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @License
config
Package config @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @License
Package config @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @License
consts
Package consts @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @License
Package consts @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @License
utility
Package utility @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @License
Package utility @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @License
Package model @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @License
Package model @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @License
Package toolkit @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @License
Package toolkit @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @License

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL