Centos7 配置基础JAVA开发环境

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

看到以下内容表示配置成功 jdk是否配置成功

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配置成功
maven配置成功

4. Git安装

yum install git -y

安装完毕查看git版本

 git --version

git安装成功

部分环境已安装完毕, 后续安装其他部分继续补充

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章