当前位置:网站首页>RouYi-Cloud平台 ---项目的启动、登录功能是怎么实现的、怎么样创建新模块
RouYi-Cloud平台 ---项目的启动、登录功能是怎么实现的、怎么样创建新模块
2022-07-28 21:24:00 【@烟雨倾城ゝ】
RouYi-Cloud平台
1、项目启动
(1)环境准备
JDK >= 1.8 (推荐1.8版本)
Mysql >= 5.7.0 (推荐5.7版本)
Redis >= 3.0
Maven >= 3.0
Node >= 12
nacos >= 1.1.0 (ruoyi-cloud >= 3.0.0需要下载nacos >= 2.x.x版本)
sentinel >= 1.6.0
(2)后台运行
- 启动本地的Nacos2.1:startup.cmd -m standalone


- 启动本地的Redis服务


1、前往Gitee下载页面(https://gitee.com/y_project/RuoYi-Cloud (opens new window))下载解压到工作目录
2、导入到项目到idea中。
3、创建数据库ry-cloud并导入数据脚本ry_2021xxxx.sql(必须),quartz.sql(可选)
4、创建数据库ry-config并导入数据脚本ry_config_2021xxxx.sql(必须)
5、配置nacos持久化,修改conf/application.properties文件,增加支持mysql数据源配置
# db mysql
spring.datasource.platform=mysql
db.num=1
db.url.0=jdbc:mysql://localhost:3306/ry-config?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC
db.user=root
db.password=123456
提示
配置文件application.properties是在下载的nacos-server包conf目录下。
最新RuoYi-Cloud版本>=3.0.0需要下载的nacos-server必须>=2.x.x版本。
默认配置单机模式,nacos集群/多集群部署模式参考 (Nacos支持三种部署模式 (opens new window))
6、打开运行基础模块(启动没有先后顺序)
- RuoYiGatewayApplication (网关模块 必须)
- RuoYiAuthApplication (认证模块 必须)
- RuoYiSystemApplication (系统模块 必须)
- RuoYiMonitorApplication (监控中心 可选)
- RuoYiGenApplication (代码生成 可选)
- RuoYiJobApplication (定时任务 可选)
- RuoYFileApplication (文件服务 可选)


7、集成seata分布式事务(可选配置,默认不启用)
创建数据库ry-seata并导入数据脚本ry_seata_2021xxxx.sql
(3)前端运行
# 进入项目目录
cd ruoyi-ui
# 安装依赖
npm install
# 强烈建议不要用直接使用 cnpm 安装,会有各种诡异的 bug,可以通过重新指定 registry 来解决 npm 安装速度慢的问题。
npm install --registry=https://registry.npmmirror.com
# 本地开发 启动项目
npm run dev

打开浏览器,输入:(http://localhost:80 (opens new window)) 默认账户/密码 admin/admin123)
若能正确展示登录页面,并能成功登录,菜单及页面展示正常,则表明环境搭建成功

2、登录实现
(1)生成验证码
1、前端代码实现
- 基本思路
后端生成一个表达式:6+2=8
1+1=?@2
1+1=?转成图片,传到前端展示
8 存入到Redis中




- 代码实现






访问地址:http://localhost:81/dev-api/code
Vue获取图片请求的是前端,再反向代理映射到后端,解决跨域问题
/dev-api 被替换成 ’ ’ ,再映射到:http://localhost:8080,变成:http://localhost:8080/code

2、后端代码实现
3、创建新模块
(1)创建自己的模块
搭建好之后的项目结构里,ruoyi-modules是存放业务模块的位置。
ruoyi-whletest就是新增的业务。
新增业务模块并配置步骤:
- 在ruoyi-modules下,右键-new-Module,使用assistant或者initial初始化模块,填写项目描述如下




(2)修改依赖和配置文件
- 项目结构新增ruoyi-whaletset如下,删除多余的模块 ,最后如下。

- 需要修改whaletest模块下的pom.xml,打开ruoyi-modules-system的系统模块的pom.xml,将内容复制到ruoyi-whaletest下的pom文件,修改artifactId和description如下,其他不变。
<artifactId>ruoyi-whaletest</artifactId>
<description>
ruoyi-whaletest系统模块
</description>
pom文件代码内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-modules</artifactId>
<version>3.5.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>ruoyi-whaletest</artifactId>
<description>
ruoyi-whaletest模块
</description>
<dependencies>
<!-- SpringCloud Alibaba Nacos -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<!-- SpringCloud Alibaba Nacos Config -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
<!-- SpringCloud Alibaba Sentinel -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
<!-- SpringBoot Actuator -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- Swagger UI -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${swagger.fox.version}</version>
</dependency>
<!-- Mysql Connector -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.22</version>
</dependency>
<!-- RuoYi Common DataSource -->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common-datasource</artifactId>
</dependency>
<!-- RuoYi Common DataScope -->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common-datascope</artifactId>
</dependency>
<!-- RuoYi Common Log -->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common-log</artifactId>
</dependency>
<!-- RuoYi Common Swagger -->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common-swagger</artifactId>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
- ruoyi-modules模块中添加子模块,这个系统自动添加进去

- 复制ruoyi-system的resources文件夹下的banner.txt,bootstrap.yml,logback.xml文件到ruoyi-whaletest模块

- 修改banner.txt.修改ruoyi system文字为ruoyi-whale模块。
Spring Boot Version: ${spring-boot.version}
Spring Application Name: ${spring.application.name}
==========ruoyi-whale模块=====
- 修改bootstrap.yml的端口号为9205,应用名称ruoyi-whaletest
# Tomcat
server:
port: 9205
# Spring
spring:
application:
# 应用名称
name: ruoyi-whaletest
profiles:
# 环境配置
active: dev
cloud:
nacos:
discovery:
# 服务注册地址
server-addr: 127.0.0.1:8848
config:
# 配置中心地址
server-addr: 127.0.0.1:8848
# 配置文件格式
file-extension: yml
# 共享配置
shared-configs:
- application-${
spring.profiles.active}.${
spring.cloud.nacos.config.file-extension}
(3)修改logback.xml中日志存放路径为:logs/ruoyi-whaletest。
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<!-- 日志存放路径 -->
<property name="log.path" value="logs/ruoyi-whaletest" />
<!-- 日志输出格式 -->
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
<!-- 控制台输出 -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
</appender>
<!-- 系统日志输出 -->
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/info.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>INFO</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/error.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>ERROR</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 系统模块日志级别控制 -->
<logger name="com.ruoyi" level="info" />
<!-- Spring日志级别控制 -->
<logger name="org.springframework" level="warn" />
<root level="info">
<appender-ref ref="console" />
</root>
<!--系统操作日志-->
<root level="info">
<appender-ref ref="file_info" />
<appender-ref ref="file_error" />
</root>
</configuration>
- 配置nacos
(1)登录Nacos配置中心,找到配置列表,选择ruoyi-system-dev.yml,点击克隆,并更改Data Id 为ruoyi-whaletest-dev.yml. 点击开始克隆

(2)修改ruoyi-whaletest-dev.yml中typeAliasesPackage搜索包名为: com.ruoyi.whaletest

(3)修改ruoyi-gateway-dev.yml网管的配置文件,新增whaletest模块
新建业务的配置
# whaletest模块
- id: ruoyi-whaletest
uri: lb://ruoyi-whaletest
predicates:
- Path=/whaletest/**
filters:
- StripPrefix=1
完整内容如下:
spring:
redis:
host: localhost
port: 6379
password:
cloud:
gateway:
discovery:
locator:
lowerCaseServiceId: true
enabled: true
routes:
# 认证中心
- id: ruoyi-auth
uri: lb://ruoyi-auth
predicates:
- Path=/auth/**
filters:
# 验证码处理
- CacheRequestFilter
- ValidateCodeFilter
- StripPrefix=1
# 代码生成
- id: ruoyi-gen
uri: lb://ruoyi-gen
predicates:
- Path=/code/**
filters:
- StripPrefix=1
# 定时任务
- id: ruoyi-job
uri: lb://ruoyi-job
predicates:
- Path=/schedule/**
filters:
- StripPrefix=1
# 系统模块
- id: ruoyi-system
uri: lb://ruoyi-system
predicates:
- Path=/system/**
filters:
- StripPrefix=1
# 文件服务
- id: ruoyi-file
uri: lb://ruoyi-file
predicates:
- Path=/file/**
filters:
- StripPrefix=1
# whaletest模块
- id: ruoyi-whaletest
uri: lb://ruoyi-whaletest
predicates:
- Path=/whaletest/**
filters:
- StripPrefix=1
# 不校验白名单
ignore:
whites:
- /auth/logout
- /auth/login
- /*/v2/api-docs
- /csrf
更改完之后点击发布。
- 修改ruoyi-whale的应用WhaleApplication.java.参照RuoYiSystemApplication,如下。
/** * whaletest模块 * * @author whale */
@EnableCustomConfig
@EnableCustomSwagger2
@EnableRyFeignClients
@SpringBootApplication
public class WhaletestApplication {
public static void main(String[] args) {
SpringApplication.run(WhaletestApplication.class, args);
System.out.println("(◠‿◠)ノ゙ Whaletes模块启动成功 ლ(´ڡ`ლ)゙ \n" +
" .-------. ____ __ \n" +
" | _ _ \\ \\ \\ / / \n" +
" | ( ' ) | \\ _. / ' \n" +
" |(_ o _) / _( )_ .' \n" +
" | (_,_).' __ ___(_ o _)' \n" +
" | |\\ \\ | || |(_,_)' \n" +
" | | \\ `' /| `-' / \n" +
" | | \\ / \\ / \n" +
" ''-' `'-' `-..-' ");
}
}
(3)代码自动生成
- 代码生成

- 新建菜单


- 在ruoyi-whaletest模块下导入模块


(4)启动项目
- 依次找到ruoyi-gateway、ruoyi-auth、ruoyi-system、ruoyi-whaletest的启动类去启动,
注意启动顺序。网管模块和认证模块要在系统模块和代码生成模块之前。

- 启动前端

- 访问项目

边栏推荐
- 【数据库】
- (重要)初识C语言 -- 函数
- shell脚本基础——Shell运行原理+变量、数组定义
- Mspba [anomaly detection: representation_based]
- 1.8tft color screen test code (stm32f407ve)
- 【图像分割】基于方向谷形检测实现静脉纹路分割附MATLAB代码
- Goer shares and Shanghai Taisi Weida growth cooperation agreement! Special SOC jointly promotes the development of TWS headphones
- 【雷达】基于核聚类实现雷达信号在线分选附matlab代码
- No code development platform management background tutorial
- Target detection notes -yolo
猜你喜欢

Reading of "robust and communication efficient federated learning from non-i.i.d. data"
![CFA [anomaly detection: embedded_based]](/img/ee/da822a7e8b443236338d4274b066c7.png)
CFA [anomaly detection: embedded_based]

can‘t convert cuda:0 device type tensor to numpy. Use Tensor. cpu() to copy the tensor to host memory

OSV_ q AttributeError: ‘numpy. ndarray‘ object has no attribute ‘clone‘

《Shortening passengers’ travel time A dynamic metro train scheduling approach using deep reinforcem》

console.log()控制台显示...解决办法

Target detection notes - overview and common data sets

Yolov5 improvement 5: improve the feature fusion network panet to bifpn

Yolov5 improvement 4: add ECA channel attention mechanism

Target detection notes fast r-cnn
随机推荐
MySQL foundation - data query
Improvement 18 of yolov5: the loss function is improved to alpha IOU loss function
cannot resize variables that require grad
Common library code snippet pytorch_ based【tips】
Paper reading: deep forest / deep forest /gcforest
Target detection notes - overview and common data sets
记录一下关于三角函数交换积分次序的一道题
Written questions and answers of software test interview (software test question bank)
Draem+sspcab [anomaly detection: block]
[3D target detection] 3dssd (II)
Yolov5 improvement 15: network lightweight method deep separable convolution
一种分布式深度学习编程新范式:Global Tensor
The simple neural network model based on full connection layer MLP is changed to the model based on CNN convolutional neural network
Xshell7, xftp7 personal free version official download, no need to crack, no activation, download and use
No code development platform address book tutorial
Improvement 13 of yolov5: replace backbone network C3 with lightweight network efficientnetv2
无代码开发平台通讯录导出入门教程
Record a question about the order of trigonometric function exchange integrals
A new MPLS note from quigo, which must be read when taking the IE exam ---- quigo of Shangwen network
Target detection notes fast r-cnn