centos7配置基礎JAVA開發環境
1. 初始化機器
作者按照k8s高可用集羣搭建-前置條件2 進行初始化機器
2. jdk1.8安裝
jdk安裝可使用 yum 進行安裝,作者使用包安裝形式
jdk選擇1.8版本, 可在 資源 中下載。
將安裝包上傳到服務器中, 可通過WinSCP。
可直接上傳到opt文件下
cd /opt
找到上傳的jdk文件
tar -zxvf jdk-8u241-linux-x64.tar.gz
tar命令進行解壓, 解壓後可進行重命名
mv jdk1.8.0_241 jdk1.8.0
配置環境變量
vi /etc/profile
文件末尾添加
JAVA_HOME=/opt/jdk1.8.0
CLASSPATH=$JAVA_HOME/lib/
PATH=$PATH:$JAVA_HOME/bin
export PATH JAVA_HOME CLASSPATH
編輯結束保存
按鍵esc, 輸入一下命令保存退出
:wq
文件生效
source /etc/profile
驗證是否配置成功
java -version
看到以下內容表示配置成功
3. maven安裝
在官網下載maven上傳至opt目錄下
新建文件夾
將安裝包移動到/opt/maven目錄下
解壓文件
cd /opt
mkdir maven reports
mv apache-maven-3.6.3-bin.tar.gz maven
tar -zxvf apache-maven-3.6.3-bin.tar.gz
配置setting.xml
cd /opt/maven/apache-maven-3.6.3/conf
vim settings.xml
本地倉庫配置
<localRepository>/opt/maven/reports</localRepository>
鏡像配置,存在私庫則配置私庫,不存在可使用阿里庫
<mirrors>
<mirror>
<id>nexus</id>
<name>Nexus Repository</name>
<url>http://192.168.xx.xxx:8080/repository/my-public/</url>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>
私庫需要配置激活
<profiles>
<profile>
<id>jdk-1.8</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.8</jdk>
</activation>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
</properties>
</profile>
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>Nexus</id>
<url>http://192.168.xx.xxx:8080/repository/my-public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>jdk-1.8</activeProfile>
<activeProfile>nexus</activeProfile>
</activeProfiles>
保存後退出
配置maven變量
vim /etc/profile
文件末尾配置
export MAVEN_HOME=/opt/maven/apache-maven-3.6.3
export PATH=$MAVEN_HOME/bin:$PATH
保存退出, 是文件生效
source /etc/profile
驗證maven是否配置成功
mvn -v
看到以下內容則表示maven配置成功
4. Git安裝
yum install git -y
安裝完畢查看git版本
git --version
部分環境已安裝完畢, 後續安裝其他部分繼續補充