Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of Native deployment of SpringCloud Application Architecture in Rainbond Cloud

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

Most people do not understand the knowledge points of this article "Rainbond cloud native deployment of SpringCloud application architecture", so the editor summarizes the following, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "Rainbond cloud native deployment of SpringCloud application architecture" article.

Sample project details

This document uses the Pig rapid development framework as an example to demonstrate how to deploy a complete set of Spring Cloud projects on Rainbond.

Pig Microservice Architecture V2.1.0:

RBAC Rights Management system based on Spring Cloud Finchley and Spring Security OAuth3

The concept of encapsulating Element-ui based on data-driven view can be used quickly even without experience of using vue.

Provide Docker, Kubernetes, Rancher2 support for common containerization

Provide production practice of lambda, stream api and webflux

Module description: pig ├── pig-ui-front-end engineering [80] ├── pig-auth-authorized service to provide [3000] └── pig-common--system common module ├── pig-common-core-common tool class core package ├── pig-common-log-└── pig-common-security-security tool class ├── pig-config -- configuration Center [8888] ├── pig-eureka-- Service Registration and Discovery [8761] ├── pig-gateway-- Spring Cloud Gateway Gateway [9999] └── pig-upms-- General user Rights Management Module └── pigx-upms-api-- General user Rights Management system Public api Module └── pigx-upms-biz-- General user Rights Management system Business Office Management module [4000] └── pigx-visual-- graphical module ├── pigx-monitor-- Spring Boot Admin monitoring [5001] └── pigx-codegen-- graphical code generation [5003] └── pigx-zipkin-- microservice link tracking [5002]

The above modules can be divided into two categories: class libraries and services. Readers can compare their own Spring Cloud projects:

After construction, the jar package is generated, which is a collection of classes used to implement various functions, that is, the class library, such as the pig-common module in Pig.

After construction, a jar package or war package is generated, which is started by java-jar or tomcat, and the service is provided by opening a certain port, such as the pig-eureka module in Pig.

You just need to build the service module in Rainbond.

After combing, the service components that the project needs to build include:

Start sequence service component name run port component function 1pig-eureka8761spring cloud service discovery registration and discovery 2pig-config8888spring cloud configuration center 3pig-gateway9999spring cloud micro service gateway 4pig-auth3000 authorization service provides 5pig-upms-biz4000 general user rights management system business processing module 6pig-monitor5001Spring Boot Admin monitoring 7pig-codegen5003 graphical code generation 8pigzipkin5002 micro service link tracking 9pig-ui80 front end project (vue project) deployment environment description:

Deployment of pig requires the support of the following environments:

Middleware or environment required version JDK1.8 mandatory version MySQL5.7+ mandatory version Redis3.2 + mandatory version node8.0 + for running front-end project npm6.0 + for building front-end project module build

Create a new application and name it spring-cloud

Get project clone / download address: https://gitee.com/log4j/pig

Take pig-eureka as an example to demonstrate the process of building from source code:

Add service components to spring-cloud-- starting with the source code-- customize the repository:

Click New Service, and Rainbond will automatically pull the code and automatically identify the code language as Java-maven according to the pom.xml in the code root directory. Cancel and build startup options:

Click create to go to the page where the service component is not deployed. Edit the ports tab and open pig-eureka 's own port 8761:

The pig-eureka needs to be accessed by other micro-service components to register, so turn on the internal service to create dependencies later. The component also provides a web page that shows the registration and health of the micro-service component, so open the external service for external access.

Edit the build source tab and specify the pig-eureka build parameters:

Because Pig itself is a multi-module project, you need to specify the module that the current service component builds. The specified method is to build the global parameters in the Maven in the build runtime environment settings:

Clean dependency:list install-pl pig-eureka-am

The above parameters specify the normal sub-module construction method. For sub-modules in another sub-module, such as pig-codegen module, the parameters are specified as follows:

Clean dependency:list install-pl pig-visual/pig-codegen-am

In the v5.1 + version of Rainbond, you can specify the startup command for the current service component. The specified method is the startup command in the build run environment settings:

Web: java $JAVA_OPTS-Djava.security.egd=file:/dev/./urandom-jar / app/pig-eureka/target/*.jar

The format of the command is the same as Procfile.

Edit the dependencies tab to specify that the current service component depends on other service components:

Dependencies between service components can be specified at creation time. All spring cloud micro-service components depend on pig-eureka. Take pig-gateway as an example, the dependency should be added as follows:

After all the settings are completed, you can click build, and after the build is complete, the service component will run automatically.

Deploy all the service components in turn.

Deploy Mysql

The Pig microservices project requires the deployment of Mysql 5.7 + as a data source. A database initialization script is provided in the code repository:

Https://gitee.com/log4j/pig/blob/master/db/pig.sql

In order to be able to load the initialization script when the database starts, a Dockerfile is made:

FROM percona:5.7.23-stretchLABEL creater= "barnett" ENV MYSQL_VERSION=5.7.23ENV TZ=Asia/ShanghaiADD docker-entrypoint.sh / run/docker-entrypoint.shADD. / run/docker-entrypoint.sh / usr/local/bin/docker-entrypoint.shADD. / run/mysqld.cnf / etc/mysql/percona-server.conf.d/mysqld.cnfRUN fetchDeps='\ ca-certificates\ wget\' \ sed-I's bind deb.debian.orgUniqMirrors.ustc.edu.cnAccording to g' / etc/apt/sources.list;\ apt-get update;\ apt-get install- y-- no-install-recommends $fetchDeps;\ rm-rf / var/lib/apt/lists/*;\ wget-O / usr/local/bin/env2file-Q https://github.com/barnettZQG/env2file/releases/download/v0.1/env2file-linux; \ chmod + x / run/docker-entrypoint.sh & & chmod + x / usr/local/bin/env2file \ apt-get purge-y-- auto-remove $fetchDepsEXPOSE 3306VOLUME ["/ var/lib/mysql", "/ var/log/mysql"] # put the scripts in the sql directory in the code repository to the corresponding initialization directory COPY sql/*.sql / docker-entrypoint-initdb.d/# change ENTRYPOINT exec some custom commandENTRYPOINT ["/ run/docker-entrypoint.sh"] CMD ["mysqld"]

Add service components to spring-cloud-- starting with the source code-- customize the repository:

Name the service component pig-db and specify the code branch pig.

Adding? dir=5.7 at the end of the code repository address url allows Rainbond to specify the build directory as the 5.7folder under the code repository root directory.

In order for the database to work properly, and connection information can be obtained by other dependent applications of this database, several environment variables need to be set:

Environment variable name Environment variable value set location MYSQL_USERroot connection information MYSQL_HOST127.0.0.1 connection information MYSQL_PORT3306 connection information MYSQL_ROOT_PASSWORDmysqlpassword connection information MYSQL_DATABASEpig connection information

Define the configuration for multiple micro-service components to connect to the database by modifying the configuration file in pig-config:

Pig/pig-config/src/main/resources/config/pigx-auth-dev.ymlpig/pig-config/src/main/resources/config/pigx-upms-dev.yml pig/pig-config/src/main/resources/config/pigx-codegen-dev.ymlpig/pig-config/src/main/resources/config/pigx-zipkin-dev.yml.yml

An example of modification is as follows:

# data source spring: datasource: type: com.zaxxer.hikari.HikariDataSource driver-class-name: com.mysql.jdbc.Driver username: ${MYSQL_USER} password: ${MYSQL_ROOT_PASSWORD} url: jdbc:mysql://$ {MYSQL_HOST}: ${MYSQL_PORT} / ${MYSQL_DATABASE}? characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai deployment Redis

Through the Rainbond application market, Redis 4.0.13 can be installed directly.

This version of Redis provides connection information by default:

Define the configuration of all service component connection Redis by modifying the pig/pig-config/src/main/resources/config/application-dev.yml in pig-config:

An example of modification is as follows:

# Spring related spring: redis: password: ${REDIS_PASS} host: ${REDIS_HOST} deploy pig-ui

Pig-ui is a vue project written in nodejs language as the front-end static page of the whole system. Rainbond currently supports source code to build nodejs front-end projects. Reference document: NodeJS front-end language

In order to facilitate the transformation of the project, a copy of the project fork has been modified with the code address:

Https://gitee.com/dazuimao1990/pig-ui

Referring to the Rainbond code support specification, the identification file: nodestatic.json is added to the code root directory.

{"path": "dist"}

The nginx configuration file is added to the code repository: www/web.conf is used to handle proxy forwarding:

Server {listen 80; root / app/www; location ~ * ^ / (code | auth | admin | gen) {proxy_pass http://127.0.0.1:9999; proxy_connect_timeout 15s; proxy_send_timeout 15s; proxy_read_timeout 15s; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;}}

Using this code to build the source code, you can complete the deployment of pig-ui service components.

Dependent and port carding service component name dependent port internal service port external service pig-uipig-gatewayoffonpig-gatewaypig-eureka Redisonoffpig-monitorpig-eureka Redisoffoffpig-configpig-eurekaoffoffpig-upms-bizpig-eureka pig-db Redisoffoffpig-zipkinpig-eureka pig-db Redisoffonpig-authpig-eureka Redisoffoffpig-codegenpig-eureka pig-db Redisoffoff final result

After the deployment is complete, the topology diagram is as follows:

Login effect:

Login account password:

Admin

123456

The above is the content of this article on "how to Native deploy SpringCloud Application Architecture in Rainbond Cloud". I believe you all have some understanding. I hope the content shared by the editor will be helpful to you. If you want to learn more about related knowledge, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report