一、在百度网盘或官网下载nexus,并部署。
注意修改:
二、下载maven
配置settings.xml文件
<?xml version="1.0" encoding="UTF-8"?>ttings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> <!--配置本地jar安装路径 --> <localRepository>D:/MyMaven/repo/m2/</localRepository> <pluginGroups></pluginGroups> <proxies></proxies> <!--配置私服用户名和密码 --> <servers> <server> <id>releases</id> <username>admin</username> <password>admin123</password> </server> <server> <id>snapshots</id> <username>admin</username> <password>admin123</password> </server> <server> <id>thirdparty</id> <username>admin</username> <password>admin123</password> </server> </servers> <!--配置从私服中央仓库获取jar包 --> <mirrors> <mirror> <id>nexus</id> <name>internal nexus repostory</name> <url>http://localhost:8081/nexus/content/groups/public/</url> <mirrorOf>*</mirrorOf> </mirror> </mirrors> <profiles> <profile> <id>luoq-private</id> <repositories> <repository> <id>yineng</id> <url>http://localhost:8081/nexus/content/repositories/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>Team Nexus Repository</id> <url>http://localhost:8081/nexus/content/groups/public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </pluginRepository> </pluginRepositories> </profile> </profiles> </settings>
|
在项目工程中,配置pom文件
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.luoq</groupId> <artifactId>luoq-my-code</artifactId> <version>1.0-SNAPSHOT</version> <packaging>pom</packaging> <name>MyCode</name> <modules> <module>j-sjms</module> </modules> <properties> <java.version>1.8</java.version> <slf4j.version>1.7.12</slf4j.version> <logback.version>1.1.3</logback.version> </properties> <dependencies> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>${slf4j.version}</version> </dependency> <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId> <version>${logback.version}</version> </dependency> </dependencies> <build> <pluginManagement> <plugins> <!-- compiler插件, 设定JDK版本 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <encoding>UTF-8</encoding> <source>${java.version}</source> <target>${java.version}</target> <showWarnings>true</showWarnings> </configuration> </plugin> </plugins> </pluginManagement> </build> <!-- 配置部署的远程仓库 --> <distributionManagement> <repository> <id>releases</id> <name>YNedut Release Repository</name> <url>http://localhost:8081/nexus/content/repositories/releases/</url> </repository> <snapshotRepository> <id>snapshots</id> <url>http://localhost:8081/nexus/content/repositories/snapshots/</url> </snapshotRepository> </distributionManagement> </project>
|
打包部署到nexus上,双击下面的deploy.bat.
deploy.bat |
install.bat |
@echo off
echo [INFO] Deploy the jar to nexus.
cd %~dp0 cd .. call mvn clean package deploy -Dmaven.test.skip=true cd bin pause
|
@echo off
echo [INFO] Install the jar to local
cd %~dp0 cd .. call mvn clean install -Dmaven.test.skip=true pause
|
最终效果:
![](http://p.qlogo.cn/qqmail_head/tuIjaI7gAC0Oko7WGq4aXscrF3CcLNicJYCQ0FZw37Q5bniaibFKnG7nhUSichicC4ZsJsLPLicnEtLplZicDGEWwymel8SEJnMeqcn/0)