Solo 开发环境搭建详细说明(用 MySQL8 数据库,对 Solo 开发指南的环境搭建的补充)

本贴最后更新于 2007 天前,其中的信息可能已经事过境迁

1. 环境搭建综述

讲述的是 CentOS7 的系统下安装 JDK,下载配置 Maven,安装 MySQL,配置 MySQL(改密码,建库),git clone solo 项目源码,编译启动的整个过程。

  • JDK:8 或更高的版本。我们就用当前最新的 JDK12 版本。
  • Maven:2 或更高的版本。我们就用当前最新的 Maven 3.6.1
  • MySQL:默认使用 MySQL,可选择使用内嵌的 H2 Database。我们就用当前最新的 MySQL8。

2. 安装 JDK12

2.1 安装之前先 rpm -qa |grep java 检查一下系统有没有低版本的 java

[root@localhost ~]# rpm -qa |grep java
javapackages-tools-3.4.1-11.el7.noarch
java-1.8.0-openjdk-devel-1.8.0.212.b04-0.el7_6.x86_64
python-javapackages-3.4.1-11.el7.noarch
tzdata-java-2019a-1.el7.noarch
java-1.8.0-openjdk-1.8.0.212.b04-0.el7_6.x86_64
java-1.8.0-openjdk-headless-1.8.0.212.b04-0.el7_6.x86_64

2.2 用 yum -y remove java* 方法卸载低版本的 java

[root@localhost ~]# yum -y remove java*              

已加载插件:fastestmirror

正在解决依赖关系

--> 正在检查事务
---> 软件包 java-1.8.0-openjdk.x86_64.1.1.8.0.212.b04-0.el7_6 将被 删除
---> 软件包 java-1.8.0-openjdk-devel.x86_64.1.1.8.0.212.b04-0.el7_6 将被 删除
---> 软件包 java-1.8.0-openjdk-headless.x86_64.1.1.8.0.212.b04-0.el7_6 将被 删除
---> 软件包 javapackages-tools.noarch.0.3.4.1-11.el7 将被 删除
--> 解决依赖关系完成

依赖关系解决

==========================================================================================================================================================================================
 Package                                                架构                              版本                                                  源                                   大小
==========================================================================================================================================================================================
正在删除:
 java-1.8.0-openjdk                                     x86_64                            1:1.8.0.212.b04-0.el7_6                               @updates                            529 k
 java-1.8.0-openjdk-devel                               x86_64                            1:1.8.0.212.b04-0.el7_6                               @updates                             40 M
 java-1.8.0-openjdk-headless                            x86_64                            1:1.8.0.212.b04-0.el7_6                               @updates                            104 M
 javapackages-tools                                     noarch                            3.4.1-11.el7                                          @base                               156 k

事务概要
==========================================================================================================================================================================================
移除  4 软件包

安装大小:145 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在删除    : 1:java-1.8.0-openjdk-devel-1.8.0.212.b04-0.el7_6.x86_64                                                                                                               1/4 
  正在删除    : 1:java-1.8.0-openjdk-1.8.0.212.b04-0.el7_6.x86_64                                                                                                                     2/4 
  正在删除    : 1:java-1.8.0-openjdk-headless-1.8.0.212.b04-0.el7_6.x86_64                                                                                                            3/4 
  正在删除    : javapackages-tools-3.4.1-11.el7.noarch                                                                                                                                4/4 
  验证中      : 1:java-1.8.0-openjdk-devel-1.8.0.212.b04-0.el7_6.x86_64                                                                                                               1/4 
  验证中      : 1:java-1.8.0-openjdk-headless-1.8.0.212.b04-0.el7_6.x86_64                                                                                                            2/4 
  验证中      : 1:java-1.8.0-openjdk-1.8.0.212.b04-0.el7_6.x86_64                                                                                                                     3/4 
  验证中      : javapackages-tools-3.4.1-11.el7.noarch                                                                                                                                4/4 

删除:
  java-1.8.0-openjdk.x86_64 1:1.8.0.212.b04-0.el7_6       java-1.8.0-openjdk-devel.x86_64 1:1.8.0.212.b04-0.el7_6       java-1.8.0-openjdk-headless.x86_64 1:1.8.0.212.b04-0.el7_6      
  javapackages-tools.noarch 0:3.4.1-11.el7               

完毕!

再次查看一下:

[root@localhost ~]# rpm -qa |grep java
python-javapackages-3.4.1-11.el7.noarch
tzdata-java-2019a-1.el7.noarch

继续删除:

[root@localhost ~]# yum -y remove python-javapackages-3.4.1-11.el7.noarch


已加载插件:fastestmirror

正在解决依赖关系

--> 正在检查事务

---> 软件包 python-javapackages.noarch.0.3.4.1-11.el7 将被 删除
--> 解决依赖关系完成

依赖关系解决

==========================================================================================================================================================================================
 Package                                              架构                                    版本                                           源                                      大小
==========================================================================================================================================================================================
正在删除:
 python-javapackages                                  noarch                                  3.4.1-11.el7                                   @base                                   65 k

事务概要
==========================================================================================================================================================================================
移除  1 软件包

安装大小:65 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在删除    : python-javapackages-3.4.1-11.el7.noarch                                                                                                                               1/1 
  验证中      : python-javapackages-3.4.1-11.el7.noarch                                                                                                                               1/1 

删除:
  python-javapackages.noarch 0:3.4.1-11.el7                                                                                                                                               

完毕!
[root@localhost ~]# yum -y remove tzdata-java-2019a-1.el7.noarch
已加载插件:fastestmirror
正在解决依赖关系
--> 正在检查事务
---> 软件包 tzdata-java.noarch.0.2019a-1.el7 将被 删除
--> 解决依赖关系完成

依赖关系解决

==========================================================================================================================================================================================
 Package                                       架构                                     版本                                             源                                          大小
==========================================================================================================================================================================================
正在删除:
 tzdata-java                                   noarch                                   2019a-1.el7                                      @updates                                   366 k

事务概要
==========================================================================================================================================================================================
移除  1 软件包

安装大小:366 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在删除    : tzdata-java-2019a-1.el7.noarch                                                                                                                                        1/1 
  验证中      : tzdata-java-2019a-1.el7.noarch                                                                                                                                        1/1 

删除:
  tzdata-java.noarch 0:2019a-1.el7                                                                                                                                                        

完毕!

再查看一下:(没有输出说明全部删除了)

[root@localhost ~]# rpm -qa |grep java
[root@localhost ~]# 

2.3 清理完旧的 Java 环境就可以开始安装新版本的 JDK 了。

2.3.1 先用命令搜索一下服务器镜像上的 JDK 版本

注:这里搜到的都是 openjdk,要装 oracle 的 JDK 需自行去官网下载

[root@localhost ~]# yum search jdk

已加载插件:fastestmirror

Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: mirror01.idc.hinet.net
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
==================================================================================== N/S matched: jdk ====================================================================================
copy-jdk-configs.noarch : JDKs configuration files copier
java-1.6.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.6.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.6.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.6.0-openjdk-javadoc.x86_64 : OpenJDK API Documentation
java-1.6.0-openjdk-src.x86_64 : OpenJDK Source Bundle
java-1.7.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.7.0-openjdk-accessibility.x86_64 : OpenJDK accessibility connector
java-1.7.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.7.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.7.0-openjdk-headless.x86_64 : The OpenJDK runtime environment without audio and video support
java-1.7.0-openjdk-javadoc.noarch : OpenJDK API Documentation
java-1.7.0-openjdk-src.x86_64 : OpenJDK Source Bundle
java-1.8.0-openjdk.i686 : OpenJDK Runtime Environment
java-1.8.0-openjdk.x86_64 : OpenJDK Runtime Environment 8
java-1.8.0-openjdk-accessibility.i686 : OpenJDK accessibility connector
java-1.8.0-openjdk-accessibility.x86_64 : OpenJDK accessibility connector
java-1.8.0-openjdk-accessibility-debug.i686 : OpenJDK accessibility connector for packages with debug on
java-1.8.0-openjdk-accessibility-debug.x86_64 : OpenJDK 8 accessibility connector for packages with debug on
java-1.8.0-openjdk-debug.i686 : OpenJDK Runtime Environment with full debug on
java-1.8.0-openjdk-debug.x86_64 : OpenJDK Runtime Environment 8 with full debug on
java-1.8.0-openjdk-demo.i686 : OpenJDK Demos
java-1.8.0-openjdk-demo.x86_64 : OpenJDK Demos 8
java-1.8.0-openjdk-demo-debug.i686 : OpenJDK Demos with full debug on
java-1.8.0-openjdk-demo-debug.x86_64 : OpenJDK Demos 8 with full debug on
java-1.8.0-openjdk-devel.i686 : OpenJDK Development Environment
java-1.8.0-openjdk-devel.x86_64 : OpenJDK Development Environment 8
java-1.8.0-openjdk-devel-debug.i686 : OpenJDK Development Environment with full debug on
java-1.8.0-openjdk-devel-debug.x86_64 : OpenJDK Development Environment 8 with full debug on
java-1.8.0-openjdk-headless.i686 : OpenJDK Runtime Environment
java-1.8.0-openjdk-headless.x86_64 : OpenJDK Headless Runtime Environment 8
java-1.8.0-openjdk-headless-debug.i686 : OpenJDK Runtime Environment with full debug on
java-1.8.0-openjdk-headless-debug.x86_64 : OpenJDK Runtime Environment with full debug on
java-1.8.0-openjdk-javadoc.noarch : OpenJDK 8 API documentation
java-1.8.0-openjdk-javadoc-debug.noarch : OpenJDK 8 API documentation for packages with debug on
java-1.8.0-openjdk-javadoc-zip.noarch : OpenJDK 8 API documentation compressed in single archive
java-1.8.0-openjdk-javadoc-zip-debug.noarch : OpenJDK 8 API documentation compressed in single archive for packages with debug on
java-1.8.0-openjdk-src.i686 : OpenJDK Source Bundle
java-1.8.0-openjdk-src.x86_64 : OpenJDK Source Bundle 8
java-1.8.0-openjdk-src-debug.i686 : OpenJDK Source Bundle for packages with debug on
java-1.8.0-openjdk-src-debug.x86_64 : OpenJDK Source Bundle 8 for packages with debug on
java-11-openjdk.i686 : OpenJDK Runtime Environment 11
java-11-openjdk.x86_64 : OpenJDK Runtime Environment 11
java-11-openjdk-debug.i686 : OpenJDK Runtime Environment 11 with full debug on
java-11-openjdk-debug.x86_64 : OpenJDK Runtime Environment 11 with full debug on
java-11-openjdk-demo.i686 : OpenJDK Demos 11
java-11-openjdk-demo.x86_64 : OpenJDK Demos 11
java-11-openjdk-demo-debug.i686 : OpenJDK Demos 11 with full debug on
java-11-openjdk-demo-debug.x86_64 : OpenJDK Demos 11 with full debug on
java-11-openjdk-devel.i686 : OpenJDK Development Environment 11
java-11-openjdk-devel.x86_64 : OpenJDK Development Environment 11
java-11-openjdk-devel-debug.i686 : OpenJDK Development Environment 11 with full debug on
java-11-openjdk-devel-debug.x86_64 : OpenJDK Development Environment 11 with full debug on
java-11-openjdk-headless.i686 : OpenJDK Headless Runtime Environment 11
java-11-openjdk-headless.x86_64 : OpenJDK Headless Runtime Environment 11
java-11-openjdk-headless-debug.i686 : OpenJDK Runtime Environment with full debug on
java-11-openjdk-headless-debug.x86_64 : OpenJDK Runtime Environment with full debug on
java-11-openjdk-javadoc.i686 : OpenJDK 11 API documentation
java-11-openjdk-javadoc.x86_64 : OpenJDK 11 API documentation
java-11-openjdk-javadoc-debug.i686 : OpenJDK 11 API documentation for packages with debug on
java-11-openjdk-javadoc-debug.x86_64 : OpenJDK 11 API documentation for packages with debug on
java-11-openjdk-javadoc-zip.i686 : OpenJDK 11 API documentation compressed in single archive
java-11-openjdk-javadoc-zip.x86_64 : OpenJDK 11 API documentation compressed in single archive
java-11-openjdk-javadoc-zip-debug.i686 : OpenJDK 11 API documentation compressed in single archive for packages with debug on
java-11-openjdk-javadoc-zip-debug.x86_64 : OpenJDK 11 API documentation compressed in single archive for packages with debug on
java-11-openjdk-jmods.i686 : JMods for OpenJDK 11
java-11-openjdk-jmods.x86_64 : JMods for OpenJDK 11
java-11-openjdk-jmods-debug.i686 : JMods for OpenJDK 11 with full debug on
java-11-openjdk-jmods-debug.x86_64 : JMods for OpenJDK 11 with full debug on
java-11-openjdk-src.i686 : OpenJDK Source Bundle 11
java-11-openjdk-src.x86_64 : OpenJDK Source Bundle 11
java-11-openjdk-src-debug.i686 : OpenJDK Source Bundle for packages with debug on
java-11-openjdk-src-debug.x86_64 : OpenJDK Source Bundle 11 for packages with debug on
java-latest-openjdk.x86_64 : OpenJDK Runtime Environment 12
java-latest-openjdk-debug.x86_64 : OpenJDK Runtime Environment 12 with full debug on
java-latest-openjdk-demo.x86_64 : OpenJDK Demos 12
java-latest-openjdk-demo-debug.x86_64 : OpenJDK Demos 12 with full debug on
java-latest-openjdk-devel.x86_64 : OpenJDK Development Environment 12
java-latest-openjdk-devel-debug.x86_64 : OpenJDK Development Environment 12 with full debug on
java-latest-openjdk-headless.x86_64 : OpenJDK Headless Runtime Environment 12
java-latest-openjdk-headless-debug.x86_64 : OpenJDK Runtime Environment with full debug on
java-latest-openjdk-javadoc.x86_64 : OpenJDK 12 API documentation
java-latest-openjdk-javadoc-debug.x86_64 : OpenJDK 12 API documentation for packages with debug on
java-latest-openjdk-javadoc-zip.x86_64 : OpenJDK 12 API documentation compressed in single archive
java-latest-openjdk-javadoc-zip-debug.x86_64 : OpenJDK 12 API documentation compressed in single archive for packages with debug on
java-latest-openjdk-jmods.x86_64 : JMods for OpenJDK 12
java-latest-openjdk-jmods-debug.x86_64 : JMods for OpenJDK 12 with full debug on
java-latest-openjdk-src.x86_64 : OpenJDK Source Bundle 12
java-latest-openjdk-src-debug.x86_64 : OpenJDK Source Bundle 12 for packages with debug on
ldapjdk-javadoc.noarch : Javadoc for ldapjdk
icedtea-web.x86_64 : Additional Java components for OpenJDK - Java browser plug-in and Web Start implementation
ldapjdk.noarch : The Mozilla LDAP Java SDK
openprops.noarch : An improved java.util.Properties from OpenJDK

  名称和简介匹配 only,使用“search all”试试。

2.3.2 选择 java-latest-openjdk-devel.x86_64 安装。

注:列出来的 JDK 中 java-latest-openjdk-devel.x86_64 : OpenJDK Development Environment 12 就是最新版的 openjdk12。另外 java-latest-openjdk.x86_64 这个是 JRE 运行时环境,只有 java 命令,没有 javac 命令。

[root@localhost ~]# yum -y install java-latest-openjdk-devel.x86_64

已加载插件:fastestmirror

Loading mirror speeds from cached hostfile

 * base: mirrors.aliyun.com

 * epel: mirrors.tuna.tsinghua.edu.cn
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
epel/x86_64/primary_db                                                                | 6.8 MB  00:02:44     
正在解决依赖关系
--> 正在检查事务
---> 软件包 java-latest-openjdk-devel.x86_64.1.12.0.1.12-1.rolling.el7 将被 安装
--> 正在处理依赖关系 java-latest-openjdk(x86-64) = 1:12.0.1.12-1.rolling.el7,它被软件包 1:java-latest-openjdk-devel-12.0.1.12-1.rolling.el7.x86_64 需要
--> 正在检查事务
---> 软件包 java-latest-openjdk.x86_64.1.12.0.1.12-1.rolling.el7 将被 安装
--> 正在处理依赖关系 java-latest-openjdk-headless(x86-64) = 1:12.0.1.12-1.rolling.el7,它被软件包 1:java-latest-openjdk-12.0.1.12-1.rolling.el7.x86_64 需要
--> 正在检查事务
---> 软件包 java-latest-openjdk-headless.x86_64.1.12.0.1.12-1.rolling.el7 将被 安装
--> 正在处理依赖关系 tzdata-java >= 2015d,它被软件包 1:java-latest-openjdk-headless-12.0.1.12-1.rolling.el7.x86_64 需要
--> 正在处理依赖关系 javapackages-tools,它被软件包 1:java-latest-openjdk-headless-12.0.1.12-1.rolling.el7.x86_64 需要
--> 正在检查事务
---> 软件包 javapackages-tools.noarch.0.3.4.1-11.el7 将被 安装
--> 正在处理依赖关系 python-javapackages = 3.4.1-11.el7,它被软件包 javapackages-tools-3.4.1-11.el7.noarch 需要
---> 软件包 tzdata-java.noarch.0.2019a-1.el7 将被 安装
--> 正在检查事务
---> 软件包 python-javapackages.noarch.0.3.4.1-11.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

=============================================================================================================
 Package                              架构           版本                              源               大小
=============================================================================================================
正在安装:
 java-latest-openjdk-devel            x86_64         1:12.0.1.12-1.rolling.el7         epel            4.5 M
为依赖而安装:
 java-latest-openjdk                  x86_64         1:12.0.1.12-1.rolling.el7         epel            201 k
 java-latest-openjdk-headless         x86_64         1:12.0.1.12-1.rolling.el7         epel             39 M
 javapackages-tools                   noarch         3.4.1-11.el7                      base             73 k
 python-javapackages                  noarch         3.4.1-11.el7                      base             31 k
 tzdata-java                          noarch         2019a-1.el7                       updates         187 k

事务概要
=============================================================================================================
安装  1 软件包 (+5 依赖软件包)

总下载量:44 M
安装大小:190 M
Downloading packages:
(1/6): python-javapackages-3.4.1-11.el7.noarch.rpm                                    |  31 kB  00:00:00     
(2/6): javapackages-tools-3.4.1-11.el7.noarch.rpm                                     |  73 kB  00:00:00     
(3/6): tzdata-java-2019a-1.el7.noarch.rpm                                             | 187 kB  00:00:00     
warning: /var/cache/yum/x86_64/7/epel/packages/java-latest-openjdk-12.0.1.12-1.rolling.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
java-latest-openjdk-12.0.1.12-1.rolling.el7.x86_64.rpm 的公钥尚未安装
(4/6): java-latest-openjdk-12.0.1.12-1.rolling.el7.x86_64.rpm                         | 201 kB  00:00:12     
(5/6): java-latest-openjdk-devel-12.0.1.12-1.rolling.el7.x86_64.rpm                   | 4.5 MB  00:03:01     
(6/6): java-latest-openjdk-headless-12.0.1.12-1.rolling.el7.x86_64.rpm                |  39 MB  00:09:44     
-------------------------------------------------------------------------------------------------------------
总计                                                                          77 kB/s |  44 MB  00:09:44     
从 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 检索密钥
导入 GPG key 0x352C64E5:
 用户ID     : "Fedora EPEL (7) <epel@fedoraproject.org>"
 指纹       : 91e9 7d7c 4a5e 96f1 7f3e 888f 6a2f aea2 352c 64e5
 软件包     : epel-release-7-11.noarch (@extras)
 来自       : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : tzdata-java-2019a-1.el7.noarch                                                           1/6 
  正在安装    : python-javapackages-3.4.1-11.el7.noarch                                                  2/6 
  正在安装    : javapackages-tools-3.4.1-11.el7.noarch                                                   3/6 
  正在安装    : 1:java-latest-openjdk-headless-12.0.1.12-1.rolling.el7.x86_64                            4/6 
  正在安装    : 1:java-latest-openjdk-12.0.1.12-1.rolling.el7.x86_64                                     5/6 
  正在安装    : 1:java-latest-openjdk-devel-12.0.1.12-1.rolling.el7.x86_64                               6/6 
  验证中      : 1:java-latest-openjdk-12.0.1.12-1.rolling.el7.x86_64                                     1/6 
  验证中      : python-javapackages-3.4.1-11.el7.noarch                                                  2/6 
  验证中      : 1:java-latest-openjdk-headless-12.0.1.12-1.rolling.el7.x86_64                            3/6 
  验证中      : tzdata-java-2019a-1.el7.noarch                                                           4/6 
  验证中      : javapackages-tools-3.4.1-11.el7.noarch                                                   5/6 
  验证中      : 1:java-latest-openjdk-devel-12.0.1.12-1.rolling.el7.x86_64                               6/6 

已安装:
  java-latest-openjdk-devel.x86_64 1:12.0.1.12-1.rolling.el7                                                 

作为依赖被安装:
  java-latest-openjdk.x86_64 1:12.0.1.12-1.rolling.el7                                                       
  java-latest-openjdk-headless.x86_64 1:12.0.1.12-1.rolling.el7                                              
  javapackages-tools.noarch 0:3.4.1-11.el7                                                                   
  python-javapackages.noarch 0:3.4.1-11.el7                                                                  
  tzdata-java.noarch 0:2019a-1.el7                                                                           

完毕!

2.3.3 装完后查看一下 JDK 版本:(也是验证 java 和 javac 命令)

[root@localhost ~]# java -version
openjdk version "12.0.1" 2019-04-16
OpenJDK Runtime Environment 19.3 (build 12.0.1+12)
OpenJDK 64-Bit Server VM 19.3 (build 12.0.1+12, mixed mode, sharing)
[root@localhost ~]# javac -version
javac 12.0.1

3. 安装 Maven

3.1 先检查本机是否已经安装了 maven

[root@localhost ~]# mvn -v
-bash: mvn: 未找到命令

上面显示未找到命令表示没有安装 maven。

3.2 去 Maven 官网下载二进制文件。

3.2.1 我们先访问 apache-maven 网站的下载界面

maven1.png
maven.png
右键点击 apache-maven-3.6.1-bin.tar.gz 复制链接地址 http://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.6.1/binaries/apache-maven-3.6.1-bin.tar.gz

3.2.2 用 wget 下载 apache-maven-3.6.1-bin.tar.gz 到本地:

[root@localhost ~]# wget http://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.6.1/binaries/apache-maven-3.6.1-bin.tar.gz


--2019-06-23 20:45:21--  http://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.6.1/binaries/apache-maven-3.6.1-bin.tar.gz


正在解析主机 mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)... 101.6.8.193, 2402:f000:1:408:8100::1
正在连接 mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)|101.6.8.193|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:9136463 (8.7M) [application/octet-stream]
正在保存至: “apache-maven-3.6.1-bin.tar.gz”

100%[===================================================================>] 9,136,463   3.32MB/s 用时 2.6s   

2019-06-23 20:45:23 (3.32 MB/s) - 已保存 “apache-maven-3.6.1-bin.tar.gz” [9136463/9136463])

3.3 解压缩 apache-maven-3.6.1-bin.tar.gz 文件:

[root@localhost ~]# tar -zxf apache-maven-3.6.1-bin.tar.gz 
[root@localhost ~]# 

3.4 设置 maven 的路径

编辑 .bash_profile 文件(vi .bash_profile),添加 maven 路径:$HOME/apache-maven-3.6.1/bin 到 PATH 环境变量。

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs
PATH=$PATH:$HOME/bin:$HOME/apache-maven-3.6.1/bin

export PATH

3.5 切换一下用户,使 PATH 生效

当前用户是 root,用 su - 命令重新切换到 root 用户,可使 PATH 生效

[root@localhost ~]# su -
上一次登录:日 6月 23 21:02:56 CST 2019pts/0 上

3.6 查看 mvn 版本(顺便测试一下 mvn 是否可用)

[root@localhost ~]# mvn -v
Apache Maven 3.6.1 (d66c9c0b3152b2e69ee9bac180bb8fcc8e6af555; 2019-04-05T03:00:29+08:00)
Maven home: /root/apache-maven-3.6.1
Java version: 12.0.1, vendor: N/A, runtime: /usr/lib/jvm/java-12-openjdk-12.0.1.12-1.rolling.el7.x86_64
Default locale: zh_CN, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-957.21.2.el7.x86_64", arch: "amd64", family: "unix"

mvn 安装成功。

4. 安装 MySQL

假设本机之前没有安装 MySQL 或者低版本的 MySQL 已经清理了。具体操作步骤请参见第 2 章节中对 Java 低版本的清理步骤。

4.1 centos7 上安装并启动 MySQL8 的命令步骤

  • 1)wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
  • 2)yum -y install mysql80-community-release-el7-3.noarch.rpm
  • 3)yum -y install mysql-community-server (从 oracle 官网下载 mysql 速度较慢,耐心等)
  • 4)systemctl start mysqld.service (启动 mysql)

5. 配置 MySQL8

配置 MySQL8 包括修改 root 密码和建库。

5.1 获取 root@localhost 的初始密码

MySQL8 在安装后会创建一个 root@locahost 账户(与之前版本不同,MySQL8 为远程连接 root@% 和本地连接 root@locahost 提供了不同的密码验证方式)。MySQL8 将本地连接的初始密码放到了/var/log/mysqld.log 文件中;我们可以用 cat /var/log/mysqld.log | grep password 命令查看初始密码。

[root@VM_0_11_centos solo]# cat /var/log/mysqld.log | grep password


2019-06-23T03:35:57.941668Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: n=Ti,P4?J(uE

注:上面 n=Ti,P4?J(uE 就是初始密码。

5.2 使用初始密码登录 mysql

[root@VM_0_11_centos solo]# mysql -uroot -p


Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 8.0.16 MySQL Community Server - GPL

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

5.3 修改 root 密码

MySQL8 的 root 用户的验证方式变了。从下面命令结果可以看出 root 的用户的加密方式为 caching_sha2_passoword,而 navicat 连接所用的方式为 native_password。

mysql> use mysql

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

Database changed
mysql> select host, user, plugin from user;
+-----------+------------------+-----------------------+
| host      | user             | plugin                |
+-----------+------------------+-----------------------+
| %         | root             | mysql_native_password |
| localhost | mysql.infoschema | caching_sha2_password |
| localhost | mysql.session    | caching_sha2_password |
| localhost | mysql.sys        | caching_sha2_password |
| localhost | root             | caching_sha2_password |
+-----------+------------------+-----------------------+
5 rows in set (0.00 sec)

5.3.1 修改密码策略

下面开始修改密码操作,但是直接用 alter 命令改还不行,因为 123456 密太简单,不满足密码策略,查看密码策略命令如下:

mysql> SHOW VARIABLES LIKE 'validate%';

+--------------------------------------+--------+

| Variable_name                        | Value  |
+--------------------------------------+--------+
| validate_password.check_user_name    | ON     |
| validate_password.dictionary_file    |        |
| validate_password.length             | 8      |
| validate_password.mixed_case_count   | 1      |
| validate_password.number_count       | 1      |
| validate_password.policy             | MEDIUM |
| validate_password.special_char_count | 1      |
+--------------------------------------+--------+
7 rows in set (0.01 sec)

需要把 validate_password.check_user_name 改为 OFF,validate_password.length 改为 1,validate_password.policy 改为 LOW。命令如下:

mysql> set global validate_password.check_user_name=0;
Query OK, 0 rows affected (0.00 sec)

mysql> set global validate_password.length=1;
Query OK, 0 rows affected (0.00 sec)

mysql> set global validate_password.policy=0;
Query OK, 0 rows affected (0.00 sec)

mysql> SHOW VARIABLES LIKE 'validate%';

+--------------------------------------+-------+
| Variable_name                        | Value |
+--------------------------------------+-------+
| validate_password.check_user_name    | OFF   |
| validate_password.dictionary_file    |       |
| validate_password.length             | 4     |
| validate_password.mixed_case_count   | 1     |
| validate_password.number_count       | 1     |
| validate_password.policy             | LOW   |
| validate_password.special_char_count | 1     |
+--------------------------------------+-------+
7 rows in set (0.00 sec)

5.3.2 修改密码

密码策略降低要求后才可以把密码改为 123456(本地和远程的都改为 123456)

mysql> alter user'root'@'localhost' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.01 sec)

mysql> ALTER USER 'root'@'%' IDENTIFIED by '123456';
Query OK, 0 rows affected (0.01 sec)

mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

5.4 建库 solo

mysql> create database solo;
Query OK, 1 row affected (0.01 sec)

6. solo 项目配置

接下来才是主角:下载 solo 项目源码,编译启动 solo,完成开发环境搭建
注:没有装 git 命令请先用 yum -y install git 命令安装。

6.1 克隆 solo 项目

使用命令:git clone --recurse-submodules https://gitee.com/b3logos/solo.git(国内通过码云下载较快):

[root@VM_0_11_centos ~]# git clone --recurse-submodules https://gitee.com/b3logos/solo.git

Cloning into 'solo'...

remote: Enumerating objects: 44272, done.
remote: Counting objects: 100% (44272/44272), done.
remote: Compressing objects: 100% (13923/13923), done.
remote: Total 44272 (delta 24766), reused 44214 (delta 24708)
Receiving objects: 100% (44272/44272), 88.66 MiB | 2.85 MiB/s, done.
Resolving deltas: 100% (24766/24766), done.
Submodule 'src/main/webapp/skins' (https://github.com/b3log/solo-skins) registered for path 'src/main/webapp/skins'
Cloning into 'src/main/webapp/skins'...
remote: Enumerating objects: 1193, done.
remote: Counting objects: 100% (1193/1193), done.
remote: Compressing objects: 100% (732/732), done.
remote: Total 11743 (delta 845), reused 767 (delta 460), pack-reused 10550
Receiving objects: 100% (11743/11743), 23.59 MiB | 256.00 KiB/s, done.
Resolving deltas: 100% (8803/8803), done.
Submodule path 'src/main/webapp/skins': checked out 'ca0de62bddd9e3bb8732e46b4239001d7f238303'
[root@VM_0_11_centos ~]# 

6.2 启动 solo 博客系统

[root@VM_0_11_centos ~]# cd solo
[root@VM_0_11_centos ~]# mvn jetty:run

6.3 登录 solo 博客系统

http://【你的服务器IP】:8080/ 登录系统,初始化博客,大功告成。

  1. 初始化.png

  1. github 认证.png

  1. 我的博客.png

相关帖子

欢迎来到这里!

我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。

注册 关于
请输入回帖内容 ...
  • yuren0705

    楼主我按你的步骤搭建不过到最后运行的时候一直卡在 start jetty 服务那边AEAAEBE8EE1F4038BC22A5EC6C0BD869.png

    2 回复
  • 其他回帖
  • xierxy

    题主,我这边运行时出现了这个错误,是需要自己配置 jetty 吗?

    [ERROR] No plugin found for prefix 'jetty' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (/Users/apple/.m2/repository), central (https://repo.maven.apache.org/maven2)] -> [Help 1]
    [ERROR]
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.

    1 回复
  • 最新版已经没有用 Jetty 了,请参考开发指南进行搭建。

  • Dipsy-chen

    使用 github 授权时候报如下错,无法登录:要怎么解决?
    没有用过 InnoDB, 使用的是 mysql ,用 idea 调试,一点击 < 登录 github 账号后使用 > 就报如下错误日志无法写入,?
    impossible to write to binary log since BINLOG_FORMAT = STATEMENT and at least one table uses a storage engine limited to row-based logging. InnoDB is limited to row-logging when transaction isolation level is READ COMMITTED or READ UNCOMMITTED.
    image.png

    1 回复
  • 查看全部回帖