搭建maven私库之后的使用
本文使用默认的已创建好的仓库。
maven-center:中央库 (表示从中央库下载的jar包:这里可以使用代理,可以是阿里地址)
maven-releases:表示发布版,本地的发布版本到私库
maven-snapshots:表示本地发布的测试版本
如果以上的仓库不够用,或者想用自己命名的私库,就自己创建,要proxy要填写地址,本地releases版本需要选择allow deployed。
setting.xml配置:
<?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"> <localRepository>F:/java/maven-3.5.3/repositorylocalRepository> <pluginGroups> pluginGroups> <proxies> proxies> <servers> <server> <id>releaseid> <username>adminusername> <password>123456password> server> <server> <id>snapshotsid> <username>adminusername> <password>123456password> server> servers> <mirrors> <mirror> <id>nexus-aliyunid> <name>nexus-aliyunname> <url>http://maven.aliyun.com/nexus/content/groups/publicurl> <mirrorOf>centralmirrorOf> mirror> mirrors> <profiles> <repositories> <repository> <id>nexusid> <name>maven-publicname> <url>http://localhost:8081/repository/maven-public/url> <releases> <enabled>trueenabled> releases> <snapshots> <enabled>falseenabled> snapshots> repository> repositories> profiles> settings>
然后是项目里的pom.xml配置(在</project>结束标签前添加就行其他地方也行):
<distributionManagement> <repository> <id>releaseid> <name>Releasesname> <url>http://localhost:8081/repository/maven-releasesurl> repository> <snapshotRepository> <id>snapshotsid> <name>Snapshotname> <url>http://localhost:8081/repository/maven-snapshotsurl> snapshotRepository> distributionManagement>
这里配置,告诉maven要打包和发布到的地址