当前位置:网站首页>Rouyi cloud platform - how to realize the launch and login functions of the project and how to create new modules
Rouyi cloud platform - how to realize the launch and login functions of the project and how to create new modules
2022-07-28 23:08:00 【@Misty rain fell on the city】
RouYi-Cloud platform
1、 Project start
(1) Environmental preparation
JDK >= 1.8 ( recommend 1.8 edition )
Mysql >= 5.7.0 ( recommend 5.7 edition )
Redis >= 3.0
Maven >= 3.0
Node >= 12
nacos >= 1.1.0 (ruoyi-cloud >= 3.0.0 Need to download nacos >= 2.x.x edition )
sentinel >= 1.6.0
(2) Background operation
- Start the local Nacos2.1:startup.cmd -m standalone


- Start the local Redis service


1、 Go to Gitee The download page (https://gitee.com/y_project/RuoYi-Cloud (opens new window)) Download and unzip to the working directory
2、 Import to project to idea in .
3、 Create database ry-cloud And import the data script ry_2021xxxx.sql( must ),quartz.sql( Optional )
4、 Create database ry-config And import the data script ry_config_2021xxxx.sql( must )
5、 To configure nacos Persistence , modify conf/application.properties file , Increase support mysql Data source configuration
# 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
Tips
The configuration file application.properties It was downloaded nacos-server package conf Under the table of contents .
newest RuoYi-Cloud edition >=3.0.0 Need to download nacos-server must >=2.x.x edition .
The default configuration is stand-alone mode ,nacos colony / Multi cluster deployment mode reference (Nacos Three deployment modes are supported (opens new window))
6、 Open and run the basic module ( There is no sequence for starting )
- RuoYiGatewayApplication ( Gateway module must )
- RuoYiAuthApplication ( Authentication module must )
- RuoYiSystemApplication ( System module must )
- RuoYiMonitorApplication ( The monitoring center Optional )
- RuoYiGenApplication ( Code generation Optional )
- RuoYiJobApplication ( Timing task Optional )
- RuoYFileApplication ( File service Optional )


7、 Integrate seata Distributed transactions ( Optional configuration , Not enabled by default )
Create database ry-seata And import the data script ry_seata_2021xxxx.sql
(3) Front end running
# Enter project directory
cd ruoyi-ui
# Installation dependency
npm install
# It is strongly recommended not to use it directly cnpm install , There will be all kinds of weird bug, You can do this by reassigning registry To solve npm Slow installation .
npm install --registry=https://registry.npmmirror.com
# Local development Start project
npm run dev

Open the browser , Input :(http://localhost:80 (opens new window)) Default account / password admin/admin123)
If the login page can be displayed correctly , And can successfully log in , Menu and page display is normal , It means that the environment has been built successfully

2、 Login implementation
(1) Generate verification code
1、 Front end code implementation
- The basic idea
The back end generates an expression :6+2=8
1+1=?@2
1+1=? Turn to picture , Send it to the front-end display
8 Deposit to Redis in




- Code implementation






Access address :http://localhost:81/dev-api/code
Vue It is the front end that gets the picture request , Then the reverse proxy is mapped to the back end , Solving cross domain problems
/dev-api Replaced with ’ ’ , Then map to :http://localhost:8080, become :http://localhost:8080/code

2、 Back end code implementation
3、 Create a new module
(1) Create your own modules
After the project structure is built ,ruoyi-modules It is the location where business modules are stored .
ruoyi-whletest Is the new business .
Add a new business module and configure the steps :
- stay ruoyi-modules Next , Right click -new-Module, Use assistant perhaps initial Initialization module , Fill in the item description below




(2) Modify dependencies and configuration files
- New project structure ruoyi-whaletset as follows , Delete redundant modules , Finally, as follows .

- Need modification whaletest Under the module of pom.xml, open ruoyi-modules-system Of the system module pom.xml, Copy content to ruoyi-whaletest Under the pom file , modify artifactId and description as follows , The other is constant .
<artifactId>ruoyi-whaletest</artifactId>
<description>
ruoyi-whaletest System module
</description>
pom The file code is as follows :
<?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 modular
</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 Add sub modules to the module , This system is automatically added

- Copy ruoyi-system Of resources Under folder banner.txt,bootstrap.yml,logback.xml File to ruoyi-whaletest modular

- modify banner.txt. modify ruoyi system The words are ruoyi-whale modular .
Spring Boot Version: ${spring-boot.version}
Spring Application Name: ${spring.application.name}
==========ruoyi-whale modular =====
- modify bootstrap.yml The port number of is 9205, apply name ruoyi-whaletest
# Tomcat
server:
port: 9205
# Spring
spring:
application:
# apply name
name: ruoyi-whaletest
profiles:
# Environment configuration
active: dev
cloud:
nacos:
discovery:
# Service registration address
server-addr: 127.0.0.1:8848
config:
# Configure center address
server-addr: 127.0.0.1:8848
# Profile format
file-extension: yml
# Shared configuration
shared-configs:
- application-${
spring.profiles.active}.${
spring.cloud.nacos.config.file-extension}
(3) modify logback.xml The log storage path in is :logs/ruoyi-whaletest.
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<!-- Log storage path -->
<property name="log.path" value="logs/ruoyi-whaletest" />
<!-- Log output format -->
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
<!-- Console output -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
</appender>
<!-- System log output -->
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/info.log</file>
<!-- Circular policy : Create log files based on time -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- Log file name format -->
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- The biggest history of journaling 60 God -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- Level of filtering -->
<level>INFO</level>
<!-- Operation when matching : receive ( Record ) -->
<onMatch>ACCEPT</onMatch>
<!-- Operation in case of mismatch : Refuse ( Don't record ) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/error.log</file>
<!-- Circular policy : Create log files based on time -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- Log file name format -->
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- The biggest history of journaling 60 God -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- Level of filtering -->
<level>ERROR</level>
<!-- Operation when matching : receive ( Record ) -->
<onMatch>ACCEPT</onMatch>
<!-- Operation in case of mismatch : Refuse ( Don't record ) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- System module log level control -->
<logger name="com.ruoyi" level="info" />
<!-- Spring Log level control -->
<logger name="org.springframework" level="warn" />
<root level="info">
<appender-ref ref="console" />
</root>
<!-- System operation log -->
<root level="info">
<appender-ref ref="file_info" />
<appender-ref ref="file_error" />
</root>
</configuration>
- To configure nacos
(1) Sign in Nacos Configuration center , Find the configuration list , choice ruoyi-system-dev.yml, Click clone , And change Data Id by ruoyi-whaletest-dev.yml. Click Start cloning

(2) modify ruoyi-whaletest-dev.yml in typeAliasesPackage Search package name is : com.ruoyi.whaletest

(3) modify ruoyi-gateway-dev.yml Configuration file of network management , newly added whaletest modular
Create a new business configuration
# whaletest modular
- id: ruoyi-whaletest
uri: lb://ruoyi-whaletest
predicates:
- Path=/whaletest/**
filters:
- StripPrefix=1
The whole content is as follows :
spring:
redis:
host: localhost
port: 6379
password:
cloud:
gateway:
discovery:
locator:
lowerCaseServiceId: true
enabled: true
routes:
# authentication center
- id: ruoyi-auth
uri: lb://ruoyi-auth
predicates:
- Path=/auth/**
filters:
# Verification code processing
- CacheRequestFilter
- ValidateCodeFilter
- StripPrefix=1
# Code generation
- id: ruoyi-gen
uri: lb://ruoyi-gen
predicates:
- Path=/code/**
filters:
- StripPrefix=1
# Timing task
- id: ruoyi-job
uri: lb://ruoyi-job
predicates:
- Path=/schedule/**
filters:
- StripPrefix=1
# System module
- id: ruoyi-system
uri: lb://ruoyi-system
predicates:
- Path=/system/**
filters:
- StripPrefix=1
# File service
- id: ruoyi-file
uri: lb://ruoyi-file
predicates:
- Path=/file/**
filters:
- StripPrefix=1
# whaletest modular
- id: ruoyi-whaletest
uri: lb://ruoyi-whaletest
predicates:
- Path=/whaletest/**
filters:
- StripPrefix=1
# Do not verify whitelist
ignore:
whites:
- /auth/logout
- /auth/login
- /*/v2/api-docs
- /csrf
Click publish after the change .
- modify ruoyi-whale Application WhaleApplication.java. reference RuoYiSystemApplication, as follows .
/** * whaletest modular * * @author whale */
@EnableCustomConfig
@EnableCustomSwagger2
@EnableRyFeignClients
@SpringBootApplication
public class WhaletestApplication {
public static void main(String[] args) {
SpringApplication.run(WhaletestApplication.class, args);
System.out.println("(◠‿◠)ノ゙ Whaletes Module started successfully ლ(´ڡ`ლ)゙ \n" +
" .-------. ____ __ \n" +
" | _ _ \\ \\ \\ / / \n" +
" | ( ' ) | \\ _. / ' \n" +
" |(_ o _) / _( )_ .' \n" +
" | (_,_).' __ ___(_ o _)' \n" +
" | |\\ \\ | || |(_,_)' \n" +
" | | \\ `' /| `-' / \n" +
" | | \\ / \\ / \n" +
" ''-' `'-' `-..-' ");
}
}
(3) Code auto generation
- Code generation

- New menu


- stay ruoyi-whaletest Import modules under modules


(4) Start project
- Find... In turn ruoyi-gateway、ruoyi-auth、ruoyi-system、ruoyi-whaletest The startup class of ,
Pay attention to the starting sequence . The network management module and authentication module should be before the system module and code generation module .

- Start the front end

- Visit the project

边栏推荐
- It's settled! All products of Nezha s will be launched on July 31
- Improvement 16 of yolov5: replace backbone network C3 with lightweight network pp-lcnet
- 【MySQL系列】 MySQL表的增删改查(进阶)
- Migration from IPv4 to IPv6
- 《Shortening passengers’ travel time A dynamic metro train scheduling approach using deep reinforcem》
- The industry's first cloud native security detection dual model! Safety dog heavyweight report appears at the digital China Construction Summit
- WebApplicationType#deduceFromClasspath
- Use FFT, matrix multiplication and conv2d to calculate convolution based on pytorch
- 【复制】互联网术语、简称、缩写
- Paper reading vision gnn: an image is worth graph of nodes
猜你喜欢

一种分布式深度学习编程新范式:Global Tensor

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

Nacos配置热更新的4种方式、读取项目配置文件的多种方式,@value,@RefreshScope,@NacosConfigurationProperties

Improvement 13 of yolov5: replace backbone network C3 with lightweight network efficientnetv2

No code development platform management background tutorial

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

Sqlilabs-3 (entry notes)

Sqlilabs-1 (breakthrough record)

frontiers出版社投稿记录(附状态变化)

shell脚本基础——Shell运行原理+变量、数组定义
随机推荐
记录一下关于三角函数交换积分次序的一道题
c语言进阶篇:指针(二)
DIP-VBTV: Color Image Restoration Model Combining Deep Image Prior and Vector Bundle Total Variation
Anaconda environment installation skimage package
Target detection notes - overview and common data sets
Goer shares and Shanghai Taisi Weida growth cooperation agreement! Special SOC jointly promotes the development of TWS headphones
Thesis reading (2) - vggnet of classification
轮子六:QSerialPort 串口数据 收发
Invest 50billion yuan! SMIC capital was officially registered!
[filter tracking] target tracking based on EKF, TDOA and frequency difference positioning with matlab code
《Shortening passengers’ travel time A dynamic metro train scheduling approach using deep reinforcem》
[physical application] atmospheric absorption loss with matlab code
MySQL数据库的基本概念以及MySQL8.0版本的部署(一)
Stm32f4 serial port burning [flymcu]
[image segmentation] vein segmentation based on directional valley detection with matlab code
一份来自奎哥的全新MPLS笔记,考IE必看 ----尚文网络奎哥
Summary of C language learning content
【MongoDB】MongoDB数据库的基础使用,特殊情况以及Mongoose的安装和创建流程(含有Mongoose固定版本安装)
A new MPLS note from quigo, which must be read when taking the IE exam ---- quigo of Shangwen network
cnpm安装步骤