SpringCloud combat project full set of learning tutorials in serial
PassJava learning tutorial
Introduction
- The PassJava-Learning project is a learning tutorial for the PassJava project. Explain the main points of architecture, business and technology.
- PassJava is an
面试刷题
open source system for Java . You can use small programs to view common interview questions in a fraction of the time to consolidate the foundation of Java. - PassJava project can teach you how to build SpringBoot project, Spring Cloud project
- Use popular technologies such as SpringBoot, MyBatis, Redis, MySql, MongoDB, RabbitMQ, Elasticsearch, and adopt Docker containerized deployment.
Better reading experience
- Document address: http://www.jayh.club
- Alternate address: https://jackson0714.github.io/PassJava-Learning
Document serialization directory
- Create a small program that brushes Java knowledge
- Create a small program that brushes Java knowledge (2)
- 01. Understand distributed basic concepts in five minutes
- 02. Quickly build a Linux environment-essential for operation and maintenance
- 03. Configure the virtual machine network
- 04. Install Docker
- 05.Docker install mysql
- 06.Docker install redis
- 07. Local development environment configuration
- 08. Configure Git
- 09. Initialize the project and add microservices
- 10.PassJava-micro service division diagram
- 11. Initialize the database and tables
- 12. Build management background
- 13. Automatically generate front-end and back-end codes
- 14. Integrate MyBatis-Plus to achieve CRUD
- 15. Generate CRUD code for all microservices
- 16. Introduction to Spring Cloud Alibaba components
- 17.SpringCloud integrates Alibaba-Nacos components
- 18.SpringCloud integrates OpenFeign components
Integrate Spring Cloud Alibaba Nacos components
Nacos is Alibaba's open source dynamic service discovery, configuration management and service management platform that is easier to build cloud-native applications.
1. Introduce Nacos service discovery component
The pom.xml file of the passjava-common module introduces the Nacos service discovery component
<!-- nacos discovery 服务发现组件-->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
2. Download and start Nacos Server
- Download the Nacos Server compressed package
https://github.com/alibaba/nacos/releases
Start the Server, enter the decompressed folder or the compiled and packaged folder, find the following relative folder nacos / bin, and compare the following commands under the actual operating system.
- Linux / Unix / Mac operating system, execute commands
sh startup.sh -m standalone
- Windows operating system, execute commands
cmd startup.cmd
Windows encountered problems executing startupm.cmd:
λ startup.cmd
Please set the JAVA_HOME variable in your environment, We need java(x64)! jdk8 or later is better!
solution:
Modify% JAVA_HOME% in startup.cmd file
%JAVA_HOME% 替换为 C:\Program Files\Java\jdk1.8.0_131
Successful start:
3. Each microservice is configured with Nacos Server address
- Configure Nacos Server address
Configure the Nacos Server address in the /src/main/resources/application.yml configuration file of the passjava-question, passjava-channel, passjava-content, passjava-member, and passjava-study applications
spring:
cloud:
nacos:
discovery:
server-addr: 127.0.0.1:8848
4. Add annotations
Use @EnableDiscoveryClient annotation for each service to enable service registration and discovery
@EnableDiscoveryClient
@MapperScan("com.jackson0714.passjava.question.dao")
@SpringBootApplication
public class PassjavaQuestionApplication {
public static void main(String[] args) {
SpringApplication.run(PassjavaQuestionApplication.class, args);
}
}
5. Configure the name of the microservice
spring:
application:
name: passjava-question
6. Access the nacos server background
- Login background
http://localhost:8848/nacos/index.html#/login
Username: nacos
Password: nacos
-
View registered services
passjava-channel 渠道微服务 passjava-member 用户微服务 passjava-study 学习微服务 passjava-question 问题微服务 passjava-content 内容微服务
Code address
https://github.com/Jackson0714/PassJava-Platform