{"id":44026,"date":"2024-10-06T12:16:17","date_gmt":"2024-10-06T04:16:17","guid":{"rendered":"https:\/\/server.hk\/cnblog\/44026\/"},"modified":"2024-10-06T12:16:17","modified_gmt":"2024-10-06T04:16:17","slug":"centos-%e5%ae%89%e8%a3%9d-nexus%ef%bc%88maven-%e7%a7%81%e6%9c%89%e5%ba%ab%ef%bc%89%e8%a9%b3%e7%b4%b0%e9%85%8d%e7%bd%ae%e5%8f%8a%e4%b8%8a%e5%82%b3%e6%9c%ac%e5%9c%b0-jar-%e5%88%b0%e7%a7%81%e6%9c%8d","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/44026\/","title":{"rendered":"CentOS \u5b89\u88dd Nexus\uff08Maven \u79c1\u6709\u5eab\uff09\u8a73\u7d30\u914d\u7f6e\u53ca\u4e0a\u50b3\u672c\u5730 jar \u5230\u79c1\u670d"},"content":{"rendered":"<h1 id=\"centos-%e5%ae%89%e8%a3%9d-nexus%ef%bc%88maven-%e7%a7%81%e6%9c%89%e5%ba%ab%ef%bc%89%e8%a9%b3%e7%b4%b0%e9%85%8d%e7%bd%ae%e5%8f%8a%e4%b8%8a%e5%82%b3%e6%9c%ac%e5%9c%b0-jar-%e5%88%b0%e7%a7%81%e6%9c%8d-miPoSzlYum\">CentOS \u5b89\u88dd Nexus\uff08Maven \u79c1\u6709\u5eab\uff09\u8a73\u7d30\u914d\u7f6e\u53ca\u4e0a\u50b3\u672c\u5730 jar \u5230\u79c1\u670d<\/h1>\n<p>Nexus Repository Manager \u662f\u4e00\u500b\u5f37\u5927\u7684\u5de5\u5177\uff0c\u80fd\u5920\u5e6b\u52a9\u958b\u767c\u8005\u7ba1\u7406\u548c\u5b58\u5132 Maven \u4f9d\u8cf4\u9805\u3002\u672c\u6587\u5c07\u8a73\u7d30\u4ecb\u7d39\u5982\u4f55\u5728 CentOS \u7cfb\u7d71\u4e0a\u5b89\u88dd Nexus\uff0c\u4e26\u914d\u7f6e Maven \u79c1\u6709\u5eab\uff0c\u6700\u5f8c\u9084\u6703\u8aaa\u660e\u5982\u4f55\u5c07\u672c\u5730\u7684 jar \u6587\u4ef6\u4e0a\u50b3\u5230\u79c1\u670d\u4e2d\u3002<\/p>\n<h2 id=\"%e4%b8%80%e3%80%81%e7%92%b0%e5%a2%83%e6%ba%96%e5%82%99-miPoSzlYum\">\u4e00\u3001\u74b0\u5883\u6e96\u5099<\/h2>\n<p>\u5728\u958b\u59cb\u5b89\u88dd Nexus \u4e4b\u524d\uff0c\u60a8\u9700\u8981\u78ba\u4fdd\u60a8\u7684 CentOS \u7cfb\u7d71\u5df2\u7d93\u5b89\u88dd\u4e86 Java\u3002Nexus \u9700\u8981 Java 8 \u6216\u66f4\u9ad8\u7248\u672c\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6aa2\u67e5 Java \u662f\u5426\u5df2\u5b89\u88dd\uff1a<\/p>\n<pre><code>java -version<\/code><\/pre>\n<p>\u5982\u679c\u672a\u5b89\u88dd Java\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88dd OpenJDK\uff1a<\/p>\n<pre><code>sudo yum install java-1.8.0-openjdk<\/code><\/pre>\n<h2 id=\"%e4%ba%8c%e3%80%81%e4%b8%8b%e8%bc%89-nexus-miPoSzlYum\">\u4e8c\u3001\u4e0b\u8f09 Nexus<\/h2>\n<p>\u63a5\u4e0b\u4f86\uff0c\u60a8\u9700\u8981\u4e0b\u8f09 Nexus \u7684\u6700\u65b0\u7248\u672c\u3002\u60a8\u53ef\u4ee5\u8a2a\u554f Nexus \u7684\u5b98\u65b9\u7db2\u7ad9\uff0c\u627e\u5230\u6700\u65b0\u7248\u672c\u7684\u4e0b\u8f09\u93c8\u63a5\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4e0b\u8f09 Nexus\uff1a<\/p>\n<pre><code>wget https:\/\/download.sonatype.com\/nexus\/3\/latest-unix.tar.gz<\/code><\/pre>\n<p>\u4e0b\u8f09\u5b8c\u6210\u5f8c\uff0c\u89e3\u58d3\u7e2e\u6587\u4ef6\uff1a<\/p>\n<pre><code>tar -zxvf latest-unix.tar.gz<\/code><\/pre>\n<h2 id=\"%e4%b8%89%e3%80%81%e5%ae%89%e8%a3%9d-nexus-miPoSzlYum\">\u4e09\u3001\u5b89\u88dd Nexus<\/h2>\n<p>\u89e3\u58d3\u7e2e\u5f8c\uff0c\u60a8\u6703\u770b\u5230\u4e00\u500b\u540d\u70ba nexus-3.x.x-xx \u7684\u6587\u4ef6\u593e\u3002\u9032\u5165\u8a72\u6587\u4ef6\u593e\uff1a<\/p>\n<pre><code>cd nexus-3.x.x-xx<\/code><\/pre>\n<p>\u63a5\u4e0b\u4f86\uff0c\u60a8\u9700\u8981\u5275\u5efa\u4e00\u500b\u7528\u65bc\u904b\u884c Nexus \u7684\u7528\u6236\uff1a<\/p>\n<pre><code>sudo useradd -r -m -U -d \/opt\/nexus -s \/bin\/false nexus<\/code><\/pre>\n<p>\u7136\u5f8c\uff0c\u5c07 Nexus \u6587\u4ef6\u593e\u7684\u6240\u6709\u6b0a\u8f49\u79fb\u7d66\u8a72\u7528\u6236\uff1a<\/p>\n<pre><code>sudo chown -R nexus:nexus \/opt\/nexus<\/code><\/pre>\n<h2 id=\"%e5%9b%9b%e3%80%81%e9%85%8d%e7%bd%ae-nexus-miPoSzlYum\">\u56db\u3001\u914d\u7f6e Nexus<\/h2>\n<p>\u5728 Nexus \u7684\u6839\u76ee\u9304\u4e0b\uff0c\u60a8\u9700\u8981\u7de8\u8f2f\u914d\u7f6e\u6587\u4ef6\u4ee5\u8a2d\u7f6e Nexus \u7684\u904b\u884c\u74b0\u5883\u3002\u6253\u958b <code>nexus.vmoptions<\/code> \u6587\u4ef6\uff1a<\/p>\n<pre><code>sudo vi \/opt\/nexus\/bin\/nexus.vmoptions<\/code><\/pre>\n<p>\u5728\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u884c\u4ee5\u8a2d\u7f6e Java \u5806\u5927\u5c0f\uff1a<\/p>\n<pre><code>-Xms1200m\n-Xmx1200m<\/code><\/pre>\n<p>\u63a5\u4e0b\u4f86\uff0c\u60a8\u9700\u8981\u7de8\u8f2f <code>nexus.properties<\/code> \u6587\u4ef6\u4ee5\u8a2d\u7f6e Nexus \u7684\u7aef\u53e3\u548c\u5176\u4ed6\u53c3\u6578\uff1a<\/p>\n<pre><code>sudo vi \/opt\/nexus\/etc\/nexus.properties<\/code><\/pre>\n<p>\u78ba\u4fdd\u4ee5\u4e0b\u884c\u88ab\u6b63\u78ba\u8a2d\u7f6e\uff1a<\/p>\n<pre><code>application-port=8081<\/code><\/pre>\n<h2 id=\"%e4%ba%94%e3%80%81%e5%95%9f%e5%8b%95-nexus-miPoSzlYum\">\u4e94\u3001\u555f\u52d5 Nexus<\/h2>\n<p>\u73fe\u5728\uff0c\u60a8\u53ef\u4ee5\u555f\u52d5 Nexus \u670d\u52d9\u3002\u9996\u5148\uff0c\u5207\u63db\u5230 Nexus \u7528\u6236\uff1a<\/p>\n<pre><code>sudo su - nexus<\/code><\/pre>\n<p>\u7136\u5f8c\u904b\u884c\u4ee5\u4e0b\u547d\u4ee4\u555f\u52d5 Nexus\uff1a<\/p>\n<pre><code>.\/bin\/nexus start<\/code><\/pre>\n<p>\u60a8\u53ef\u4ee5\u901a\u904e\u8a2a\u554f <code>http:\/\/your-server-ip:8081<\/code> \u4f86\u6aa2\u67e5 Nexus \u662f\u5426\u904b\u884c\u6b63\u5e38\u3002<\/p>\n<h2 id=\"%e5%85%ad%e3%80%81%e9%85%8d%e7%bd%ae-maven-%e7%a7%81%e6%9c%89%e5%ba%ab-miPoSzlYum\">\u516d\u3001\u914d\u7f6e Maven \u79c1\u6709\u5eab<\/h2>\n<p>\u5728 Nexus \u754c\u9762\u4e2d\uff0c\u60a8\u53ef\u4ee5\u5275\u5efa\u4e00\u500b\u65b0\u7684 Maven \u79c1\u6709\u5eab\u3002\u9ede\u64ca\u5de6\u5074\u7684 <strong>Repositories<\/strong>\uff0c\u7136\u5f8c\u9078\u64c7 <strong>Create repository<\/strong>\u3002\u9078\u64c7 <strong>Maven2 (hosted)<\/strong>\uff0c\u4e26\u586b\u5beb\u76f8\u95dc\u4fe1\u606f\u3002<\/p>\n<h2 id=\"%e4%b8%83%e3%80%81%e4%b8%8a%e5%82%b3%e6%9c%ac%e5%9c%b0-jar-%e5%88%b0%e7%a7%81%e6%9c%8d-miPoSzlYum\">\u4e03\u3001\u4e0a\u50b3\u672c\u5730 jar \u5230\u79c1\u670d<\/h2>\n<p>\u8981\u5c07\u672c\u5730\u7684 jar \u6587\u4ef6\u4e0a\u50b3\u5230 Nexus \u79c1\u670d\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528 Maven \u7684 <code>deploy:deploy-file<\/code> \u547d\u4ee4\u3002\u4ee5\u4e0b\u662f\u4e00\u500b\u793a\u4f8b\u547d\u4ee4\uff1a<\/p>\n<pre><code>mvn deploy:deploy-file -DgroupId=com.example -DartifactId=my-artifact -Dversion=1.0 -Dpackaging=jar -Dfile=\/path\/to\/your\/file.jar -DrepositoryId=nexus-repo -Durl=http:\/\/your-server-ip:8081\/repository\/maven-releases\/<\/code><\/pre>\n<p>\u78ba\u4fdd\u5c07\u547d\u4ee4\u4e2d\u7684\u53c3\u6578\u66ff\u63db\u70ba\u60a8\u7684\u5be6\u969b\u503c\u3002<\/p>\n<h2 id=\"%e7%b8%bd%e7%b5%90-miPoSzlYum\">\u7e3d\u7d50<\/h2>\n<p>\u672c\u6587\u4ecb\u7d39\u4e86\u5982\u4f55\u5728 CentOS \u4e0a\u5b89\u88dd Nexus\uff0c\u914d\u7f6e Maven \u79c1\u6709\u5eab\uff0c\u4e26\u4e0a\u50b3\u672c\u5730 jar \u6587\u4ef6\u5230\u79c1\u670d\u3002\u9019\u4e9b\u6b65\u9a5f\u80fd\u5920\u5e6b\u52a9\u958b\u767c\u8005\u66f4\u6709\u6548\u5730\u7ba1\u7406\u4f9d\u8cf4\u9805\uff0c\u63d0\u5347\u958b\u767c\u6548\u7387\u3002\u5982\u679c\u60a8\u9700\u8981\u7a69\u5b9a\u7684 <a href=\"https:\/\/server.hk\">VPS<\/a> \u670d\u52d9\u4f86\u904b\u884c\u60a8\u7684 Nexus\uff0c\u8acb\u8003\u616e\u4f7f\u7528\u6211\u5011\u7684\u89e3\u6c7a\u65b9\u6848\uff0c\u78ba\u4fdd\u60a8\u7684\u958b\u767c\u74b0\u5883\u9ad8\u6548\u4e14\u53ef\u9760\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8a73\u7d30\u6b65\u9a5f\u6559\u4f60\u5728 CentOS \u4e0a\u5b89\u88dd Nexus\uff0c\u914d\u7f6e Maven \u79c1\u6709\u5eab\uff0c\u4e26\u4e0a\u50b3\u672c\u5730 JAR \u6a94\u6848\u81f3\u79c1\u670d\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4924],"tags":[],"class_list":["post-44026","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/44026","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=44026"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/44026\/revisions"}],"predecessor-version":[{"id":44027,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/44026\/revisions\/44027"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=44026"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=44026"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=44026"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}