CentOS7下安装JDK、Tomcat及Maven
下载
- 下载jdk
//jdk需要注册oracle账号才能下载,这里提供一个本人下载好的 链接: https://pan.baidu.com/s/1zBISqJRXY8glsKh9JyZPew 密码: kb5e // 上传到服务器 scp jdk-8u201-linux-x64.tar.gz root@121.37.4.145:/opt
121.37.4.145是我购买的服务器公网ip
- 下载maven
cd /opt wget https://archive.apache.org/dist/maven/maven-3/3.6.1/binaries/apache-maven-3.6.1-bin.tar.gz
- 下载tomcat
cd /opt wget http://archive.apache.org/dist/tomcat/tomcat-9/v9.0.20/bin/apache-tomcat-9.0.20.tar.gz
解压并重命名
- 解压
tar -zvxf jdk-8u201-linux-x64.tar.gz tar -zxvf apache-maven-3.6.1-bin.tar.gz tar -zxvf apache-tomcat-9.0.20.tar.gz
- 移动到usr目录下
mv jdk1.8.0_201/ /usr/local/java mv apache-maven-3.6.1 /usr/local/maven mv apache-tomcat-9.0.20 /usr/local/tomcat
- 配置环境变量
vim /etc/profile
末尾加入:
# jdk export JAVA_HOME=/usr/local/java export JRE_HOME=${JAVA_HOME}/jre export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib export PATH=${JAVA_HOME}/bin:$PATH # maven export M2_HOME=/usr/local/maven export PATH=${M2_HOME}/bin:$PATH # tomcat export TOMCAT_HOME=/usr/local/tomcat
生效:
source /etc/profile
效果截图:
Maven切换阿里源,速递更快!
修改mavensettings文件
vim /usr/local/maven/conf/settings.xml
找到 localRepository 标签 ,添加
<localRepository>/opt/maven-repository</localRepository>
找到 profiles 标签,添加
<profile> <id>aliyun</id> <!-- repositories and pluginRepositories here --> <repositories> <repository> <id>nexus-aliyun</id> <name>Nexus aliyun</name> <url>http://maven.aliyun.com/nexus/content/groups/public</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> </profile> <activeProfiles> <activeProfile>aliyun</activeProfile> </activeProfiles>