簡介:
學之思開源考試系統(tǒng)是一款 java + vue 的前后端分離的考試系統(tǒng)。主要優(yōu)點是開發(fā)、部署簡單快捷、界面設計友好、代碼結構清晰。支持web端和微信小程序,能覆蓋到pc機和手機等設備。 支持多種部署方式:集成部署、前后端分離部署、docker部署。
集成部署
環(huán)境 | 版本 | 下載地址 |
---|---|---|
NodeJs | 16 | https://nodejs.org/download/release/latest-v16.x/ |
Jdk | 1.8 | https://www.oracle.com/java/technologies/downloads/ |
Mysql | 8.0/5.7 | https://dev.mysql.com/downloads/ |
數(shù)據(jù)庫腳本下載地址:https://www.mindskip.net:999,創(chuàng)建表初始化數(shù)據(jù),數(shù)據(jù)庫名稱為xzs
代碼下載 mysql版本,配合相應的數(shù)據(jù)庫使用
安裝mysql ,導入xzs-mysql.sql腳本
學生端默認賬號:student / 123456
管理端默認賬號:admin / 123456
實操
所有操作都在一臺服務器實施,前后端不分離
安裝打包工具
安裝jdk
[root@web-nginx ~]# tar xzvf jdk-8u221-linux-x64.tar.gz -C /usr/local/
[root@web-nginx ~]# mv /usr/local/jdk1.8.0_221/ /usr/local/java
配置環(huán)境變量
[root@web-nginx ~]# vim /etc/profile
JAVA_HOME=/usr/local/java
PATH=$JAVA_HOME/bin:$PATH
export JAVA_HOME PATH
重載環(huán)境變量
[root@web-nginx ~]# source /etc/profile
查看java是否安裝成功
[root@web-nginx ~]# java -version
java version "1.8.0_211"
Java(TM) SE Runtime Environment (build 1.8.0_211-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.211-b12, mixed mode)
安裝maven
[root@web-nginx ~]# wget https://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.8.8/binaries/apache-maven-3.8.8-bin.tar.gz
解壓并改名
[root@web-nginx ~]# tar xzvf apache-maven-3.8.8-bin.tar.gz -C /usr/local/
[root@web-nginx ~]# mv /usr/local/apache-maven-3.8.8/ /usr/local/maven
設置環(huán)境變量
[root@web-nginx ~]# vim /etc/profile
MAVEN_HOME=/usr/local/maven
PATH=$PATH:$MAVEN_HOME/bin
export MAVEN_HOME PATH
重載環(huán)境變量
[root@web-nginx ~]# source /etc/profile
檢測maven是否安裝成功
[root@web-nginx ~]# mvn -version
Apache Maven 3.8.8 (4c87b05d9aedce574290d1acc98575ed5eb6cd39)
Maven home: /usr/local/maven
Java version: 1.8.0_211, vendor: Oracle Corporation, runtime: /usr/local/java/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-1160.el7.x86_64", arch: "amd64", family: "unix"
安裝node.js前端打包工具命令npm
[root@web-nginx ~]# wget https://nodejs.org/download/release/latest-v16.x/node-v16.20.2-linux-x64.tar.xz
[root@web-nginx ~]# tar xf node-v16.20.2-linux-x64.tar.xz -C /usr/local/
[root@web-nginx ~]# cd /usr/local/
[root@web-nginx local]# mv node-v16.20.2-linux-x64/ node
配置環(huán)境變量
[root@web-nginx ~]# vim /etc/profile
NODE_HOME=/usr/local/node
PATH=$NODE_HOME/bin:$PATH
export NODE_HOME PATH
重載環(huán)境變量
[root@web-nginx ~]# source /etc/profile
查看是否安裝成功,查看版本
[root@web-nginx ~]# node --version
v16.20.2
獲取源代碼
安裝Git命令獲取源代碼
[root@web-nginx ~]# yum install -y git
獲取clone代碼
[root@web-nginx ~]# git clone https://gitee.com/hyunze/xzs-mysql.git
安裝mysql5.7
[root@web-nginx ~]# wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
[root@web-nginx ~]# rpm -ivh mysql80-community-release-el7-3.noarch.rpm
[root@web-nginx ~]# vim /etc/yum.repos.d/mysql-community.repo
將mysql8.0關閉將mysql5.7開啟
enabled=1
gpgcheck=0
[root@web-nginx ~]# yum install -y mysql-community-server
啟動mysql
[root@web-nginx ~]# systemctl start mysqld
過濾第一次登錄所需的密碼
[root@web-nginx ~]# grep pass /var/log/mysqld.log
改密碼
[root@web-nginx ~]# mysqladmin -uroot -p'HdV>.f>Ir8;h' password 'QianFeng@123!'
[root@web-nginx ~]# mysql -uroot -p'QianFeng@123!'
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.31 MySQL Community Server (GPL)
...
創(chuàng)建數(shù)據(jù)庫xzs
mysql> create database xzs character set utf8 collate utf8_general_ci;
Query OK, 1 row affected (0.00 sec)
設置root允許遠程登錄
mysql> update mysql.user set host = '%' where user = 'root';
Query OK, 1 row affected (0.10 sec)
Rows matched: 1 Changed: 1 Warnings: 0
刷新權限
mysql> flush privileges;
mysql> \q
Bye
配置mysql環(huán)境
修改mysql
[root@web-nginx ~]# vim xzs-mysql/source/xzs/src/main/resources/application-prod.yml
logging:
path: /usr/log/xzs/
spring:
datasource:
url: jdbc:mysql://192.168.1.101:3306/xzs?useSSL=false&useUnicode=true&serverTimezone=Asia/Shanghai&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&allowPublicKeyRetrieval=true&allowMultiQueries=true
username: root
password: QianFeng@123!
driver-class-name: com.mysql.cj.jdbc.Driver
#####url那一行 ip改為自己做實驗服務器的ip,/ ?的名字改為自己之前創(chuàng)建數(shù)據(jù)庫的名字。password改為遠程登錄MySQL數(shù)據(jù)庫的密碼
導入初始化mysql
[root@web-nginx ~]# mysql -uroot -p'QianFeng@123!' xzs < xzs-mysql/sql/xzs-mysql.sql
前端打包
學生端
[root@web-nginx ~]# cd xzs-mysql/source/vue/xzs-student/
打包
[root@web-nginx xzs-student]# npm config set sass_binary_site https://npm.taobao.org/mirrors/node-sass/
[root@web-nginx xzs-student]# npm install --registry https://registry.npm.taobao.org
[root@web-nginx xzs-student]# npm run build
[root@web-nginx xzs-student]# cp -r student xzs-mysql/source/xzs/src/main/resources/static
管理端
[root@web-nginx ~]# cd xzs-mysql/source/vue/xzs-admin/
打包
[root@web-nginx xzs-admin]# npm config set sass_binary_site https://npm.taobao.org/mirrors/node-sass/
[root@web-nginx xzs-admin]# npm install --registry https://registry.npm.taobao.org
[root@web-nginx xzs-admin]# npm run build
[root@web-nginx xzs-admin]# cp -r admin xzs-mysql/source/xzs/src/main/resources/static
將java程序打包成jar包
這時候進行打包,所使用的鏡像源是國外的源,因此會導致打包時間巨長,打包超時,打包失敗,為了杜絕這種現(xiàn)象,我們可以采用阿里云的鏡像源
打開? ?maven鏡像_maven下載地址_maven安裝教程-阿里巴巴開源鏡像站 (aliyun.com)https://developer.aliyun.com/mirror/maven?spm=a2c6h.13651102.0.0.3e221b11gh5cgw
配置maven的配置文件,替換鏡像源
vim /usr/local/maven/conf/settings.xml
將源文件里的內容替換為
這時開始打包? 速度就會很快
[root@web-nginx ~]# cd xzs-mysql/source/xzs
[root@web-nginx xzs]# mvn package
服務上線
[root@web-nginx ~]# mkdir -p /application/java-server
[root@web-nginx ~]# cp xzs-mysql/source/xzs/target/xzs-3.9.0.jar /application/java-server
[root@web-nginx ~]# cd /application/java-server
讓服務在后臺運行
[root@web-nginx java-server]# nohup java -Duser.timezone=Asia/Shanghai -jar -Dspring.profiles.active=prod xzs-3.9.0.jar > start1.log 2>&1 &
成功運行的日志顯示
訪問
學生端訪問地址為:http://ip:8000/student
管理員端訪問地址為:http://ip:8000/admin??????
學生端默認賬號:student / 123456
管理端默認賬號:admin / 123456
實驗中遇到問題
1.mysql設置root允許遠程登錄,語法出現(xiàn)錯誤
2.學生端及管理端進行打包時,注意路徑的使用
3.在后端打包時,如果使用國外的源,可以替換為阿里云的鏡像源,提升打包成功率。文章來源:http://www.zghlxwxcb.cn/news/detail-745351.html
4.養(yǎng)成觀察日志的習慣,遇到錯誤在日志中尋找錯誤原因文章來源地址http://www.zghlxwxcb.cn/news/detail-745351.html
到了這里,關于云計算實戰(zhàn)項目之---學之思在線考試系統(tǒng)的文章就介紹完了。如果您還想了解更多內容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!