この記事では、主に、Mavenプライベートサーバーとミラーリング(写真とテキスト)を構築する実際の方法を紹介します。次のように、それはあなたと共有されます:
準備
3.6にNexusをインストールします。
理論
Nexusのリポジトリタイプ
Nexusビルトインウェアハウスタイプ
次の図
プライベートサーバープロセスを設定します
ステップ2に従って[testsnapshot]リポジトリを作成します
Mavenプロジェクトを構築し、POMファイルで次の情報を構成します。
<DistributionManagement> <Repository> <id>リリース</id> <url> http://192.168.0.1:8888/repository/testrelease/ </url> </repository> <snapshotrepository> <id> snapshots </id> <url> http://192.168.0.1:8888/repository/testsnapshot/ </url> </snapshotrepository> <! - ここでは、urlはリポジトリへのパスです - > </distributionmanagement> <build> <プラグイン<groupid> org.apache.maven.plugins </groupid> <artifactid> maven-jar-plugin </artifactid> <バージョン> 3.0.2 </version> <configuration> <excludes> <excludes> **/*。 <groupid> org.apache.maven.plugins </groupid> <artifactid> maven-source-plugin </artifactid> <version> 3.0.1 </version> <configuration> <true> true </attach> </configuration> <executions> <execution> <実行</plugin> </plugins> </build>
Maven、Warehouseユーザーアカウントのパスワードで設定ファイルを構成する
<サーバー> <id>リリース</id> <username> user </username> <password> 123456 </password> </server> <server> <id> snapshots </id> <username> user </username> <asfadur> 123456 </password> </server> </servers> //
MVNコマンドを入力して、パッケージ化してアップロードします
MVNクリーンソース:Jar Packagemvn Deploy -E
次のように、Nexusの[コンポーネント]をチェックしてください:成功
参照は次のとおりであり、構成は参照プロジェクトのpom.xmlで次のとおりです
<! - nexusプライベートサーバー構成 - > <リポジトリ> <リポジトリ> <id> nexus </id> <name> nexusリポジトリ</name> <url> http://192.168.2.20:8081/repository/java/ <デフォルトでオフにしてオンにする必要があります - > <SnapShots> <Enabled> true </enabled> </snapshots> </repository> </repositories> <deprosencies> <dependency> com.example </groupid> <artifactid> utils </artifactid> <バージョン>
ミラープロセスを設定します
Mavenの設定構成は次のとおりです
<Mirrors> <mirror> <id> Mirror </id> <mirrorof>*</mirrorof> <name> nexus aliyun </name> <url> http://116.62.220.224:8888/repository/testgroup/ </url> </mirrer </mirror <パスワード> 123456 </password> </server> </servers>
このように、すべてのMavenプロジェクトはこの画像からの依存関係を参照します
要約します
ミラーリングは、転送の傍受と要求に相当しますが、プライベートサーバーは、ダウンロード構造とサードパーティ構造の保存、ローカルメイベン構成などの節約などの役割を果たします。2つの組み合わせは、Mavenの利点を完全に反映できます。
上記はこの記事のすべての内容です。みんなの学習に役立つことを願っています。誰もがwulin.comをもっとサポートすることを願っています。