首先,新建一个maven项目—自己新建吧。
然后,
打开来,然后:
添加我们的maven私服及servers—用来发布类库的。
格式如下:
<?xml version="1.0" encoding="UTF-8"?> <settings 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"> <mirrors> <!--内部maven--> <mirror> <id>central</id> <mirrorOf>*</mirrorOf> <name>Central Repository</name> <url>http://你仓库的地址/repository/maven-public/</url> </mirror> <!-- 阿里云仓库 --> <mirror> <id>alimaven</id> <mirrorOf>central</mirrorOf> <name>aliyun maven</name> <url>http://maven.aliyun.com/nexus/content/repositories/central/</url> </mirror> <!-- *仓库1 --> <mirror> <id>repo1</id> <mirrorOf>central</mirrorOf> <name>Human Readable Name for this Mirror.</name> <url>http://repo1.maven.org/maven2/</url> </mirror> <!-- *仓库2 --> <mirror> <id>repo2</id> <mirrorOf>central</mirrorOf> <name>Human Readable Name for this Mirror.</name> <url>http://repo2.maven.org/maven2/</url> </mirror> </mirrors> <servers> <server> <id>nexus-releases</id> <username>admin</username> <password>你的密码</password> </server> <server> <id>nexus-snapshots</id> <username>admin</username> <password>你的密码</password> </server> </servers>
</settings>
发布快照及正式版本
maven(15),快照与发布,RELEASE与SNAPSHOT
在pom.xml文件最后添加distributionManagement发布管理节点:
例如:
<distributionManagement> <repository> <id>nexus-releases</id> <name>Nexus Release Repository</name> <url>http://你的maven地址/repository/maven-releases/</url> </repository> <snapshotRepository> <id>nexus-snapshots</id> <name>Nexus Snapshot Repository</name> <url>http://你的maven地址/repository/maven-snapshots/</url> </snapshotRepository> </distributionManagement>
- 注意一下
<groupId>net.funfunle</groupId> <artifactId>baselib</artifactId> <!--<version>1.0-SNAPSHOT</version>--> <version>1.0.1-RELEASE</version>
groupid这些,
<groupId>net.funfunle</groupId> <artifactId>baselib</artifactId> <!--<version>1.0-SNAPSHOT</version>--> <version>1.0.1-RELEASE</version>