前言
项目构建管理工具
安装
- 下载: 全平台
- 解压maven和本地repository
- 配置本地仓库
conf/settings.xml:
<localRepository>D:\develop\apache-maven-3.5.2\repository</localRepository>
- Maven环境变量
系统变量新建: MAVEN_HOME:D:\develop\apache-maven-3.5.2
path添加: %MAVEN_HOME%\bin
- 测试安装
mvn -v
配置镜像
有shadowsocks就不要配置!!!,有可能冲突。
setting.xml
<mirrors>
<mirror>
<id>alimaven</id>
<mirrorOf>central</mirrorOf>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
</mirror>
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
<mirror>
<id>central</id>
<name>Maven Repository Switchboard</name>
<url>http://repo1.maven.org/maven2/</url>
<mirrorOf>central</mirrorOf>
</mirror>
<mirror>
<id>repo2</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://repo2.maven.org/maven2/</url>
</mirror>
<mirror>
<id>ibiblio</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://mirrors.ibiblio.org/pub/mirrors/maven2/</url>
</mirror>
<mirror>
<id>jboss-public-repository-group</id>
<mirrorOf>central</mirrorOf>
<name>JBoss Public Repository Group</name>
<url>http://repository.jboss.org/nexus/content/groups/public</url>
</mirror>
<mirror>
<id>google-maven-central</id>
<name>Google Maven Central</name>
<url>https://maven-central.storage.googleapis.com
</url>
<mirrorOf>central</mirrorOf>
</mirror>
<!-- 中央仓库在中国的镜像 -->
<mirror>
<id>maven.net.cn</id>
<name>oneof the central mirrors in china</name>
<url>http://maven.net.cn/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
idea配置Maven
-
普通配置
- File --->settings --->搜索maven --->指定maven目录,配置文件路径, 本地仓库路径
-
默认配置:
- File--->other setting --->Default Settings --->搜索Maven --->指定maven目录 ,配置文件路径 , 本地仓库路径
- File--->other setting --->Default Settings --->搜索Maven --->Maven下的Runner--->设置VM options为:-DarchetypeCatalog=internal
-
设置自动修改包:
在 build-build-maven-importing里面设置自动引用
私服
安装到centos
wget https://sonatype-download.global.ssl.fastly.net/nexus/3/latest-unix.tar.gz
tar -zxvf latest-unix.tar.gz -C /usr/local/
# 启动 &表示后台
/usr/local/nexus-3.13.0-01/bin/nexus run &
访问
用户名:admin
密码:admin123
客户端配置私服
maven安装目录下的setting.xml添加:
<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>
<profile>
<!--profile 的 id-->
<id>dev</id>
<repositories>
<repository>
<!--仓库 id, repositories 可以配置多个仓库,保证 id 不重复-->
<id>nexus</id>
<!--仓库地址,即 nexus 仓库组的地址-->
<url>http://localhost:8081/nexus/content/groups/public/</url>
<!--是否下载 releases 构件-->
<releases>
<enabled>true</enabled>
</releases>
<!--是否下载 snapshots 构件-->
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<!-- 插件仓库, maven 的运行依赖插件,也需要从私服下载插件 -->
<pluginRepository>
<!-- 插件仓库的 id 不允许重复,如果重复后边配置会覆盖前边 -->
<id>public</id>
<name>Public Repositories</name>
<url>http://localhost:8081/nexus/content/groups/public/</url>
</pluginRepository>
</pluginRepositories>
</profile>
<!--激活-->
<activeProfiles>
<activeProfile>dev</activeProfile>
</activeProfiles>
idea修改指定pom
<!--发布管理节点,指定当前项目上传的仓库url地址-->
<distributionManagement>
<repository>
<id>releases</id>
<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>
项目发布到私服
deploy
jar包会自动从私服下载
从客户端导入第三方jar包
在jar包位置cmd
mvn install:install-file -DgroupId=com.alibaba -DartifactId=fastjson -Dversion=1.1.37
-Dfile= fastjson-1.1.37.jar -Dpackaging=jar