云计算实战项目之---学之思在线考试系统

打印 上一主题 下一主题

主题 547|帖子 547|积分 1641

简介:

   学之思开源考试系统是一款 java + vue 的前后端分离的考试系统。主要优点是开发、部署简单快捷、界面设计友好、代码结构清晰。支持web端和微信小步伐,能覆盖到pc机和手机等设备。 支持多种部署方式:集成部署、前后端分离部署、docker部署。
  集成部署

环境版本下载地点NodeJs16https://nodejs.org/download/release/latest-v16.x/Jdk1.8https://www.oracle.com/java/technologies/downloads/Mysql8.0/5.7https://dev.mysql.com/downloads/   数据库脚本下载地点:https://www.mindskip.net:999,创建表初始化数据,数据库名称为xzs
代码下载 mysql版本,配合相应的数据库使用
安装mysql ,导入xzs-mysql.sql脚本
学生端默认账号:student / 123456
管理端默认账号:admin / 123456
  实操

所有操纵都在一台服务器实施,前后端不分离
安装打包工具

安装jdk

  1. [root@web-nginx ~]# tar xzvf jdk-8u221-linux-x64.tar.gz -C /usr/local/
  2. [root@web-nginx ~]# mv /usr/local/jdk1.8.0_221/ /usr/local/java
  3. 配置环境变量
  4. [root@web-nginx ~]# vim /etc/profile
  5. JAVA_HOME=/usr/local/java
  6. PATH=$JAVA_HOME/bin:$PATH
  7. export JAVA_HOME PATH
  8. 重载环境变量
  9. [root@web-nginx ~]# source /etc/profile
  10. 查看java是否安装成功
  11. [root@web-nginx ~]# java -version
  12. java version "1.8.0_211"
  13. Java(TM) SE Runtime Environment (build 1.8.0_211-b12)
  14. Java HotSpot(TM) 64-Bit Server VM (build 25.211-b12, mixed mode)
复制代码
安装maven

  1. [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
  2. 解压并改名
  3. [root@web-nginx ~]# tar xzvf apache-maven-3.8.8-bin.tar.gz -C /usr/local/
  4. [root@web-nginx ~]# mv /usr/local/apache-maven-3.8.8/ /usr/local/maven
  5. 设置环境变量
  6. [root@web-nginx ~]# vim /etc/profile
  7. MAVEN_HOME=/usr/local/maven
  8. PATH=$PATH:$MAVEN_HOME/bin
  9. export MAVEN_HOME PATH
  10. 重载环境变量
  11. [root@web-nginx ~]# source /etc/profile
  12. 检测maven是否安装成功
  13. [root@web-nginx ~]#  mvn -version
  14. Apache Maven 3.8.8 (4c87b05d9aedce574290d1acc98575ed5eb6cd39)
  15. Maven home: /usr/local/maven
  16. Java version: 1.8.0_211, vendor: Oracle Corporation, runtime: /usr/local/java/jre
  17. Default locale: en_US, platform encoding: UTF-8
  18. OS name: "linux", version: "3.10.0-1160.el7.x86_64", arch: "amd64", family: "unix"
复制代码
安装node.js前端打包工具命令npm

  1. [root@web-nginx ~]# wget https://nodejs.org/download/release/latest-v16.x/node-v16.20.2-linux-x64.tar.xz
  2. [root@web-nginx ~]# tar xf node-v16.20.2-linux-x64.tar.xz -C /usr/local/
  3. [root@web-nginx ~]# cd /usr/local/
  4. [root@web-nginx local]# mv node-v16.20.2-linux-x64/ node
  5. 配置环境变量
  6. [root@web-nginx ~]# vim /etc/profile
  7. NODE_HOME=/usr/local/node
  8. PATH=$NODE_HOME/bin:$PATH
  9. export NODE_HOME PATH
  10. 重载环境变量
  11. [root@web-nginx ~]# source /etc/profile
  12. 查看是否安装成功,查看版本
  13. [root@web-nginx ~]# node --version
  14. v16.20.2
复制代码
获取源代码

安装Git命令获取源代码

  1. [root@web-nginx ~]# yum install -y git
复制代码
获取clone代码

  1. [root@web-nginx ~]# git clone https://gitee.com/hyunze/xzs-mysql.git
复制代码
安装mysql5.7

  1. [root@web-nginx ~]# wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
  2. [root@web-nginx ~]# rpm -ivh mysql80-community-release-el7-3.noarch.rpm
  3. [root@web-nginx ~]# vim /etc/yum.repos.d/mysql-community.repo
  4. 将mysql8.0关闭将mysql5.7开启
  5. enabled=1
  6. gpgcheck=0
  7. [root@web-nginx ~]# yum install -y mysql-community-server
  8. 启动mysql
  9. [root@web-nginx ~]# systemctl start mysqld
  10. 过滤第一次登录所需的密码
  11. [root@web-nginx ~]# grep pass /var/log/mysqld.log
  12. 改密码
  13. [root@web-nginx ~]# mysqladmin -uroot -p'HdV>.f>Ir8;h' password 'QianFeng@123!'
  14. [root@web-nginx ~]# mysql -uroot -p'QianFeng@123!'
  15. mysql: [Warning] Using a password on the command line interface can be insecure.
  16. Welcome to the MySQL monitor.  Commands end with ; or \g.
  17. Your MySQL connection id is 3
  18. Server version: 5.7.31 MySQL Community Server (GPL)
  19. ...
  20. 创建数据库xzs
  21. mysql> create database xzs character set utf8 collate  utf8_general_ci;
  22. Query OK, 1 row affected (0.00 sec)
  23. 设置root允许远程登录
  24. mysql> update mysql.user set host = '%' where user = 'root';
  25. Query OK, 1 row affected (0.10 sec)
  26. Rows matched: 1  Changed: 1  Warnings: 0
  27. 刷新权限
  28. mysql> flush privileges;
  29. mysql> \q
  30. Bye
复制代码
配置mysql环境

修改mysql

  1. [root@web-nginx ~]# vim xzs-mysql/source/xzs/src/main/resources/application-prod.yml
  2. logging:
  3.   path: /usr/log/xzs/
  4. spring:
  5.   datasource:
  6.     url: jdbc:mysql://192.168.1.101:3306/xzs?useSSL=false&useUnicode=true&serverTimezone=Asia/Shanghai&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&allowPublicKeyRetrieval=true&allowMultiQueries=true
  7.     username: root
  8.     password: QianFeng@123!
  9.     driver-class-name: com.mysql.cj.jdbc.Driver
  10. #####url那一行 ip改为自己做实验服务器的ip,/  ?的名字改为自己之前创建数据库的名字。password改为远程登录MySQL数据库的密码
复制代码
导入初始化mysql

  1. [root@web-nginx ~]# mysql -uroot -p'QianFeng@123!' xzs < xzs-mysql/sql/xzs-mysql.sql
复制代码
前端打包

学生端

  1. [root@web-nginx ~]# cd xzs-mysql/source/vue/xzs-student/
  2. 打包
  3. [root@web-nginx xzs-student]# npm config set sass_binary_site https://npm.taobao.org/mirrors/node-sass/
  4. [root@web-nginx xzs-student]# npm install --registry https://registry.npm.taobao.org  
  5. [root@web-nginx xzs-student]# npm run build
  6. [root@web-nginx xzs-student]# cp -r student xzs-mysql/source/xzs/src/main/resources/static
复制代码
管理端

  1. [root@web-nginx ~]# cd xzs-mysql/source/vue/xzs-admin/
  2. 打包
  3. [root@web-nginx xzs-admin]# npm config set sass_binary_site https://npm.taobao.org/mirrors/node-sass/
  4. [root@web-nginx xzs-admin]# npm install --registry https://registry.npm.taobao.org  
  5. [root@web-nginx xzs-admin]# npm run build
  6. [root@web-nginx xzs-admin]# cp -r admin xzs-mysql/source/xzs/src/main/resources/static
复制代码
将java步伐打包成jar包

这时候举行打包,所使用的镜像源是国外的源,因此会导致打包时间巨长,打包超时,打包失败,为了杜绝这种现象,我们可以采用阿里云的镜像源
打开   maven镜像_maven下载地点_maven安装教程-阿里巴巴开源镜像站 (aliyun.com)
https://developer.aliyun.com/mirror/maven?spm=a2c6h.13651102.0.0.3e221b11gh5cgw

配置maven的配置文件,更换镜像源
  1. vim  /usr/local/maven/conf/settings.xml
复制代码
将源文件里的内容更换为

这时开始打包  速度就会很快
  1. [root@web-nginx ~]# cd xzs-mysql/source/xzs
  2. [root@web-nginx xzs]# mvn package
复制代码
服务上线

  1. [root@web-nginx ~]# mkdir -p /application/java-server
  2. [root@web-nginx ~]# cp xzs-mysql/source/xzs/target/xzs-3.9.0.jar /application/java-server
  3. [root@web-nginx ~]# cd /application/java-server
  4. 让服务在后台运行
  5. [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允许远程登录,语法出现错误
  2.学生端及管理端举行打包时,注意路径的使用
  3.在后端打包时,假如使用国外的源,可以更换为阿里云的镜像源,提升打包成功率。
  4.养成观察日志的风俗,遇到错误在日志中探求错误缘故原由

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

万有斥力

金牌会员
这个人很懒什么都没写!

标签云

快速回复 返回顶部 返回列表