<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                [TOC] # 簡介 公司在自己的局域網內搭建自己的遠程倉庫服務器,稱為私服,私服服務器即是公司內部的 maven 遠程倉庫,每個員工的電腦上安裝 maven 軟件并且連接私服服務器,員工將自 己開發的項目打成 jar 并發布到私服服務器,其它項目組從私服服務器下載所依賴的構件 (jar)。 私服還充當一個代理服務器,當私服上沒有 jar 包會從互聯網中央倉庫自動下載,如下 圖: ![](https://img.kancloud.cn/3e/7b/3e7b5954619100317f33a2b9f2b592d8_435x387.png) 下載 Nexus, 下載地址:http://www.sonatype.org/nexus/archived/ [https://help.sonatype.com/repomanager3/download](https://help.sonatype.com/repomanager3/download) windows要 cmd 進入 bin 目錄,執行 `nexus.bat install` cmd 進入 bin 目錄,執行 `nexus.bat start` # 配置文件 nexus.properties是配置文件 ~~~ # Jetty section application-port=8081 # nexus 的訪問端口配置 application-host=0.0.0.0 # nexus 主機監聽配置(不用修改) nexus-webapp=${bundleBasedir}/nexus # nexus 工程目錄 nexus-webapp-context-path=/nexus # nexus 的 web 訪問路徑 # Nexus section nexus-work=${bundleBasedir}/../sonatype-work/nexus # nexus 倉庫目錄 runtime=${bundleBasedir}/nexus/WEB-INF # nexus 運行程序目錄 ~~~ wrapper.conf這個文件下面改下java的這個 ~~~ wrapper.java.command=/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/bin/java ~~~ 默認密碼 admin和admin123 [http://127.0.0.1:8081/nexus](http://127.0.0.1:8081/nexus) ![](https://img.kancloud.cn/9b/ad/9badeb1170202484e88a7637c70a52f4_324x214.png) 這個里面可以改密碼 # 倉庫類型 nexus 的倉庫有 4 種類型: ![](https://img.kancloud.cn/16/58/1658f87ed1301919d5ced0d8bb97f7ae_360x310.png) 1. hosted,宿主倉庫,部署自己的 jar 到這個類型的倉庫,包括 releases 和 snapshot 兩部 分,Releases公司內部發布版本倉庫、 Snapshots 公司內部測試版本倉庫 2. proxy,代理倉庫,用于代理遠程的公共倉庫,如 maven 中央倉庫,用戶連接私服,私服自動去中央倉庫下載 jar 包或者插件。 3. group,倉庫組,用來合并多個 hosted/proxy 倉庫,通常我們配置自己的 maven 連接倉庫組。 4. virtual(虛擬):兼容Maven1 版本的jar或者插件 nexus 倉庫默認在 sonatype-work 目錄中: ![](https://img.kancloud.cn/94/a5/94a5d1c0a8cadc9196b76aa269b79296_193x228.png) * central:代理倉庫,代理中央倉庫 ![](https://img.kancloud.cn/87/0a/870a682b6b7b606ded8a6e6d9ece75f7_710x426.png) * apache-snapshots:代理倉庫 存儲 snapshots 構件,代理地址 https://repository.apache.org/snapshots/ ? central-m1:virtual 類型倉庫,兼容 Maven1 版本的 jar 或者插件 ? releases:本地倉庫,存儲releases構件。 * snapshots:本地倉庫,存儲snapshots構件。 * thirdparty:第三方倉庫 * public:倉庫組 ![](https://img.kancloud.cn/99/6e/996ee21490107cc8c357df47729ec404_1142x1406.png) # 發布到私服 ## 需求 企業中多個團隊協作開發通常會將一些公用的組件、開發模塊等發布到私服供其它團隊 或模塊開發人員使用。 本例子假設多團隊分別開發 ssm\_dao、ssm\_service、ssm\_web,某個團隊開發完在 ssm\_dao 會將 ssm\_dao 發布到私服供 ssm\_service 團隊使用,本例子會將 ssm\_dao 工程打成 jar 包發布到私服。 ![](https://img.kancloud.cn/4c/ab/4cabba5b86274e8ef9cf6aed987509b6_636x207.png) ## 配置 第一步:需要在客戶端即部署ssm\_dao工程的電腦上配置 maven環境,并修改 settings.xml 文件,配置連接私服的用戶和密碼 。 此用戶名和密碼用于私服校驗,因為私服需要知道上傳的賬號和密碼是否和私服中的賬號和 密碼一致。 ~~~ <server> <id>releases</id> <username>admin</username> <password>admin123</password> </server> <server> <id>snapshots</id> <username>admin</username> <password>admin123</password> </server> ~~~ releases 連接發布版本項目倉庫 snapshots 連接測試版本項目倉庫 ![](https://img.kancloud.cn/4e/d3/4ed321f1f6c6efe853a48ae86a5ad125_735x81.png) 第二步: 配置項目 pom.xml 配置私服倉庫的地址,本公司的自己的 jar 包會上傳到私服的宿主倉庫,根據工程的版本號 決定上傳到哪個宿主倉庫,如果版本為 release 則上傳到私服的 release 倉庫,如果版本為 snapshot 則上傳到私服的 snapshot 倉庫 url是私服網頁上的對應倉庫的url ![](https://img.kancloud.cn/e0/af/e0af9e8b24d74ab206585f239ca5b33b_1454x258.png) ~~~ <distributionManagement> <repository> <id>releases</id> <name>Nexus Release Repository</name> <url>http://localhost:8081/nexus/content/repositories/releases/</url> </repository> <snapshotRepository> <id>snapshots</id> <name>Nexus Snapshot Repository</name> <url>http://localhost:8081/nexus/content/repositories/snapshots/</url> </snapshotRepository> </distributionManagement> ~~~ 注意:pom.xml 這里 和 settings.xml 配置對應 你要在dao中把包上傳就在dao中deploy的 根據本項目 pom.xml 中 version 定義決定發布到哪個倉庫, 如果 version 定義為 snapshot, 執行 deploy 后查看 nexus 的 snapshot 倉庫, 如果 version 定義為 release 則項目將發布到 nexus 的 release 倉庫,本項目將發布到 release 倉庫. **測試** 可以通過 http 方式查看 ![](https://img.kancloud.cn/b3/0a/b30a149b147f8e8bf875c1442537f295_706x222.png) # 從私服下載jar包 ## 需求 沒有配置 nexus 之前,如果本地倉庫沒有,去中央倉庫下載,通常在企業中會在局域網 內部署一臺私服服務器,有了私服本地項目首先去本地倉庫找 jar, 如果沒有找到則連接私 服從私服下載 jar 包,如果私服沒有 jar 包私服同時作為代理服務器從中央倉庫下載 jar 包, 這樣做的好處是一方面由私服對公司項目的依賴 jar 包統一管理,一方面提高下載速度,項 目連接私服下載 jar 包的速度要比項目連接中央倉庫的速度快的多。 **在 setting.xml 中配置倉庫** 在客戶端的 setting.xml 中配置私服的倉庫,由于 setting.xml 中沒有 repositories 的配置 標簽需要使用 profile 定義倉庫。 ~~~ <profile> <!--profile 的 id--> <id>dev</id> <repositories> <repository> <!--倉庫 id,repositories 可以配置多個倉庫,保證 id 不重復--> <id>nexus</id> <!--倉庫地址,即 nexus 倉庫組的地址--> <url>http://localhost:8081/nexus/content/groups/public/</url> <!--是否下載 releases 構件--> <releases> <enabled>true</enabled> </releases> <!--是否下載 snapshots 構件--> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> <pluginRepositories> <!-- 插件倉庫,maven 的運行依賴插件,也需要從私服下載插件 --> <pluginRepository> <!-- 插件倉庫的 id 不允許重復,如果重復后邊配置會覆蓋前邊 --> <id>public</id> <name>Public Repositories</name> <url>http://localhost:8081/nexus/content/groups/public/</url> </pluginRepository> </pluginRepositories> </profile> ~~~ 使用 profile 定義倉庫需要激活才可生效 ~~~ <activeProfiles> <activeProfile>dev</activeProfile> </activeProfiles> ~~~ ![](https://img.kancloud.cn/01/f6/01f6e1005b56e191fa574ca1466d7e1c_919x402.png) # 第三方jar包安裝到本地或私服 1. 導入本地庫 2種方式 ~~~ ----進入jar包所在目錄運行 mvn install:install-file -DgroupId=com.alibaba -DartifactId=fastjson -Dversion=1.1.37 -Dfile=fastjson-1.1.37.jar -Dpackaging=jar ----打開cmd直接運行 mvn install:install-file -DgroupId=com.alibaba -DartifactId=fastjson -Dversion=1.1.37 -Dpackaging=jar -Dfile=C:\my_java\fastjson-1.1.37.jar ~~~ 然后去倉庫看下 2. 導入私服 需要在 maven 軟件的核心配置文件 settings.xml 中配置第三方倉庫的 server 信息 要能登錄到第三方 ~~~ <server> <id>thirdparty</id> <username>admin</username> <password>admin123</password> </server> ~~~ 才能執行一下命令 2種方式 ~~~ ----進入jar包所在目錄運行 mvn deploy:deploy-file -DgroupId=com.alibaba -DartifactId=fastjson -Dversion=1.1.37 -Dpackaging=jar -Dfile=fastjson-1.1.37.jar -Durl=http://localhost:8081/nexus/content/repositories/thirdparty/ -DrepositoryId=thirdparty ----打開cmd直接運行 mvn deploy:deploy-file -DgroupId=com.alibaba -DartifactId=fastjson -Dversion=1.1.37 -Dpackaging=jar -Dfile=C:\my_java\fastjson-1.1.37.jar -Durl=http://localhost:8081/nexus/content/repositories/thirdparty/ -DrepositoryId=thirdparty ~~~ **參數說明** DgroupId 和 DartifactId 構成了該 jar 包在 pom.xml 的坐標,項目就是依靠這兩個屬性定位。 自己起名字也行。 Dfile 表示需要上傳的 jar 包的絕對路徑。 Durl 私服上倉庫的位置,打開 `nexus——>repositories` 菜單,可以看到該路徑。 DrepositoryId 服務器的表示 id,在 nexus 的 configuration 可以看到。 Dversion 表示版本信息, **關于 jar 包準確的版本: ** 包的名字上一般會帶版本號,如果沒有那可以解壓該包,會發現一個叫 MANIFEST.MF 的文件, 這個文件就有描述該包的版本信息。 比如 Specification-Version: 2.2 可以知道該包的版本了。 上傳成功后,在 nexus 界面點擊 3rd party 倉庫可以看到這包。 # 多個私服切換 setting.xml 家和公司兩套 activeProfiles屬性指定id ![](https://img.kancloud.cn/6d/5e/6d5eb1b7628df7be8f5a484a07ef934f_584x488.png) # nexus3界面 > Repository:倉儲系統 * Blob Stores:這個可以看成是存儲空間,管理空間,主要是進行管理Repositorles中倉庫的,默認有一個default存儲,可以創建存儲空間 * Reposltorles:倉庫,這就是我們所說的倉庫的概念了,倉庫一共分為三種類型,宿主(hosted),代理(proxy)和分組(group) * 宿主:第三方構建所能上傳的倉庫,可以創建多個name屬性不同的宿主倉庫,用于管理不同的項目 * 代理:訪問網絡nexus服務器,用途:打個比方的說,想使用Junit包,但是分組倉庫中沒有,就需要去訪問網絡上的中央倉庫中下載到你的代理倉庫.(因為實際從網絡倉庫中download的是代理倉庫,ps:默認訪問網絡中倉庫的是游客,這個無需去計較了!) * 分組:分組倉庫的主要作用就是將你的宿主倉庫和代理倉庫進行連接,比如說不同的項目創建的不通的宿主倉庫,卻使用了相同的代理倉庫.這種就可以使用分組倉庫進行連接!!!!!!! * Content Selectors:未知,不了解.從大概的意思上就是nexus組件的使用,和創建自己的組件 > Security:安全管理,賬號的權限,SSL證書的配置都在這里 * Prlvileges:每種倉庫的增刪改查,瀏覽等權限,可以單獨進行配置,被使用于Roles * Roles:角色權限,相當于一個權限模板,提供給User使用!默認有兩種權限,一個是游客(anonymous),一個是管理員(admin) * Users:用戶,這個就是訪問nexus私服的用戶了,默認同樣是有兩個,一個是管理員(admin),一個是游客(anonymous),管理員繼承了Roles中admin權限模板,具有所有管理權限,而游客只有瀏覽權限 * Anonymous:游客(或者叫匿名用戶) 請忽略他 * LDAP:通訊錄? 不了解,請忽略他 * Realms:領域?什么領域? 不了解,請忽略他 * SSL Certlficates:SSL證書配置 > Support:支持,分析系統運行狀態,系統信息,日志查看都在這里 * Analytlcs:分析你的組組件在如何的使用Nexus * Logging:系統各項組件日志 * Metrlcs:內存,線程,磁盤目前使用圖 * Support ZIP:選擇Support中各種分析文件打成ZIP文件,其中包括系統的運行狀態啊,JVM啊,配置文件啊,日志啊等等之類的! * System InforMation:系統信息,這個比較常用,可以看Nexus運行狀態,版本信息,配置文件,組件信息等..... -- System:系統設置 * Bundles:系統插件具體信息的查看,我是這么理解的!有問題,請留言! * Capabilities:管理和配置你的Nexus具有什么能力,正常使用默認的就好! * Email Server:Email服務的配置,用于發郵件(在系統出現問題時) * HTTP: 整體傳輸協議的配置,默認的就好! * Licensing:許可證配置,SSL許可證? * Recent Connections:7天內訪問系統信息,都誰訪問過nexus服務器 * Nodes:節點管理? * Tasks:系統任務 ## 倉庫創建 登錄管理界面Administration->Repository->Repositories->左上角Create repository(創建倉庫) 我們創建一個Maven2類型的宿主(hosted)倉庫(Maven2(hosted)),以下步驟下圖所示 ![](https://img.kancloud.cn/af/38/af383edceefaa08f0531c9e83eeaf926_672x626.png) 上圖提到了Storage倉儲的這點,那么下圖就去創建一個倉儲,倉儲是可以創建多個的,每個倉儲可以存儲不通類型倉庫的數據\_ 創建倉儲:Repository->Blob Stores->Create blob store,下圖所示 ![](https://img.kancloud.cn/94/07/94075ff0966b13fc7f6bfa3d4f1e9e56_751x293.png) 創建步驟重述:先創建倉儲,在創建倉庫,創建倉庫時選擇你創建的倉儲,就可以了(一個倉庫只能選擇一個倉儲) ## 權限管理 Nexus的權限控制采用的是典型的權限(Privilege)和角色(Role)機制。角色與權限是一對多的關聯,用戶與角色也是一對多的關聯。由于Nexus的主要功能就是管理Maven倉庫,所以其權限(Privilege)主要是對倉庫進行CRUD(增查改刪)操作的權限。作為Nexus的用戶,我們能進行管理的就是對倉庫的增刪改查權限,其他的例如UI權限等是Nexus內建的,用戶無法增刪改,這個在下一節會講到。 單個權限(Privilege)所能控制的級別是一個倉庫(Repository,包括Group)中存儲路徑匹配指定正則表達式的一組項目(Artifact)的增刪查改(create,delete,read,update)中的某一個操作。正因為其使用了正則表達式來選定要控制的Artifact所以非常靈活。 Nexus的權限分為三類: 1. 應用權限(Application Privilege):主要是用戶的UI操作權限和系統管理權限,例如通過UI登錄、進行用戶管理等。 2. 倉庫目標權限(Repository Target Privilege):我們作為用戶能自定義的唯一一種權限,就是對倉庫中的項目的CRUD操作權限。 3. 倉庫瀏覽權限(Repository View Privilege):通過UI界面瀏覽一個倉庫的權限,在創建每個倉庫時,Nexus會自動創建一個對應該倉庫的View權限,擁有該倉庫的view權限才能在系統的Repositories視圖中看到該倉庫。 以上三類權限中,應用權限和倉庫瀏覽權限兩種是由Nexus創建的,我們并不能對這些權限進行增刪改操作,只能選擇使用或不使用它們。我們能自定義的權限只有倉庫目標權限 --- 創建用戶:Security->Users->左上角Create user,創建詳細如圖所示: ![](https://img.kancloud.cn/cc/a4/cca4c546e9ab8f777cf57bbe2dce0164_649x659.png) 創建用戶需要一個用戶所屬的模板,可以繼承多個模板,相當于同時有了多種模板所具有權限,下面進行創建一個模板 創建角色模板:Security->Roles->Create Role->Nexus role ![](https://img.kancloud.cn/bd/9c/bd9c28b152182d1b66823eddfb756e93_510x549.png) Privileges: 管理倉庫的多種權限,以一個我創建的倉庫 aaa截圖說明: ![](https://img.kancloud.cn/4a/85/4a85f6abf72a99090479824111176312_1457x750.png) 強調:權限管理步驟復述,需要先具有一個角色模板(roles),同時也需要一個Privileges(當構建倉庫的時候,默認會構建完成),之后創建User,鏈接所屬Role就可以了* ## 訪問 setting.xml 在`<mirrors></mirrors>`標簽中添加`mirror`子節點: ~~~xml <mirror> <id>maven-private</id> <mirrorOf>maven-private</mirrorOf> <url>https://repo.liming.pub/nexus/repository/maven-private/</url> </mirror> ~~~ 或者在`<prifiles></prifiles>`標簽中增加增加profile子節點: ~~~xml <profile> <id>maven-private</id> <repositories> <repository> <id>maven-private</id> <url>https://repo.liming.pub/nexus/repository/maven-private/</url> <snapshots> <updatePolicy>always</updatePolicy> </snapshots> </repository> </repositories> </profile> ~~~ 在`<servers></servers>`標簽中添加`server`子節點: ~~~xml <server> <id>maven-private</id> <username>用戶名</username> <password>密碼</password> </server> ~~~ 工程pom中增加發布倉庫配置 ~~~xml <profiles> <profile> <id>maven-protect</id> <distributionManagement> <repository> <id>maven-protect-releases</id> <url>https://repo.liming.pub/nexus/repository/maven-protect-releases/</url> </repository> <repository> <id>maven-protect-snapshots</id> <url>https://repo.liming.pub/nexus/repository/maven-protect-snapshots/</url> </repository> </distributionManagement> </profile> <profile> <id>maven-private</id> <distributionManagement> <repository> <id>maven-private-releases</id> <url>https://repo.liming.pub/nexus/repository/maven-private-releases/</url> </repository> <repository> <id>maven-private-snapshots</id> <url>https://repo.liming.pub/nexus/repository/maven-private-snapshots/</url> </repository> </distributionManagement> </profile> </profiles> ~~~ 在setting.xml的`<servers></servers>`標簽中添加`server`子節點 ~~~xml <server> <id>maven-private-snapshots</id> <username>用戶名</username> <password>密碼</password> </server> <server> <id>maven-private-releases</id> <username>用戶名</username> <password>密碼</password> </server> ~~~ ## 部署命令 通過maven 的-P參數激活指定的profile 參數的值是profile的id,多個profile以逗號分割,如果不想激活某個默認的profile,就在它的id前加個! ~~~ mvn deploy -Pmaven-private ~~~ 查看當前生效的profile: ~~~ mvn help:active-profiles -Pmaven-private ~~~ # maven離線使用 要在無網絡訪問的環境下使用maven,由于私有倉庫無法同步中央倉庫,這種情況下,可以將本地倉庫整個打包拷貝過去。注意要將各個目錄下的`_remote.repositories`文件刪除,否則maven也不會使用本地倉庫的jar。 刪除命令如下: ~~~ find ~/.m2/ -name _maven.repositories | xargs rm ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看