(1)首先下载maven,下载地址 http://maven.apache.org/download.cgi
然后上传:apache-maven-3.0.4-bin.tar.gz
解压命令:tar -zxvf apache-maven-3.0.4-bin.tar.gz
移动命令:mv apache-maven-3.0.4 /usr/local/apache-maven-3.0.4
(2)配置maven环境变量:
编辑命令:vim /etc/profile
编辑内容:
#maven
export MAVEN_HOME=/usr/local/apache-maven-3.0.4
export PATH=.:$ZOOKEEPER_HOME/bin:$STORM_HOME/bin:$JAVA_HOME/bin:$MAVEN_HOME/bin:$PATH
重新启动 source /etc/profile 生效
(3)进行 maven 的 settings.xml 配置
命令:vim /usr/local/apache-maven-3.0.4/conf/settings.xml
修改内容,详见 settings.xml
<localRepository>/usr/local/apache-maven-3.0.4/Repository</localRepository>
<!--配置权限,使用默认用户-->
<servers>
<server>
<id>nexus-releases</id>
<username>deployment</username>
<password>deployment123</password>
</server>
<server>
<id>nexus-snapshots</id>
<username>deployment</username>
<password>deployment123</password>
</server>
</servers>
<profiles>
<profile>
<id>nexus-bhz</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.7</jdk>
</activation>
<properties>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<maven.compiler.compilerVersion>1.7</maven.compiler.compilerVersion>
</properties>
<repositories>
<!-- 私有库地址-->
<repository>
<id>nexus</id>
<url>http://localhost:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<!--插件库地址-->
<pluginRepository>
<id>nexus</id>
<url>http://localhost:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<!-- 激活 -->
<activeProfiles>
<activeProfile>nexus-bhz</activeProfile>
</activeProfiles>
建立 Repository 文件夹 存放的是 从私服上面下载下来的包。
命令: mkdir /usr/local/apache-maven-3.0.4/Repository