Previously, I have shared the relevant knowledge of SpringBoot, for example:
1. 1SpringBoot one day quick start, super liver goods! [i]
2. SpringBoot one day quick start, super liver goods! [II]
Of course, I also shared a lot of SpringBoot projects. These projects are really good!
1. Online education system sharing based on springboot
2. System sharing of activity management applet based on springboot
3. Microservice project sharing based on springcloud [video tutorial + source code]
4. After finishing this springboot project, I am familiar with boot [video tutorial + source code]
If you want to learn SpringBoot+vue, it is recommended to learn this springboot music project. There are no bug s in the system, and it is beautiful. The most important thing is that we recorded a detailed tutorial, which took more than half a year. The whole network broadcast volume is almost 20w+, and the purpose is to help small partners learn quickly, which is highly praised.
Original | music website system based on Springboot+Vue [detailed tutorial] [with source code]
Many of the projects and materials I shared are better than those you spent 2w in training institutions!
Pay attention to me early, don't get lost!
No more nonsense. Let's start with SpringCloud and distributed.
catalogue
l single application architecture
l vertical application architecture
l distributed service architecture
4, Spring Boot and Spring Cloud
This course introduces the zookeeper+dubbo combination commonly used in China in distributed systems, and Spring Boot recommends the use of full stack Spring, Spring Boot+Spring Cloud.
At present, SpringBoot is the mainstream Java development framework. Before the interview, you must work on several SpringBoot projects. But SpringBoot is really huge.
Then let me slowly decompose and keep learning!
First, let's take a look at all the learning routes of Java:
Let's look at the number of micro services:
We can see that there are many technologies of distributed microservices, so try not to say you are proficient during the interview, or you will lose your tongue!
I. Video Explanation
Video is the most intuitive form. If you don't like reading articles, you can directly move to the video area to watch videos:
Spring Boot and distributed video learning
If you like reading articles, we'd better continue. We suggest that you like your collection. Otherwise, you won't find this article if you brush it.
2, Distributed application
In distributed systems, the combination of zookeeper+dubbo is commonly used in China, while Spring Boot recommends using the full stack Spring, Spring Boot+Spring Cloud.
Distributed system:
l single application architecture
When the website traffic is small, only one application is needed to deploy all functions together to reduce deployment nodes and costs. At this point, the data access framework (ORM) used to simplify the workload of adding, deleting, modifying and querying is the key.
l vertical application architecture
When the number of visits increases gradually, the acceleration caused by the increase of a single application becomes smaller and smaller. The application is divided into several unrelated applications to improve efficiency. At this point, the Web framework (MVC) for accelerating front-end page development is the key.
l distributed service architecture
When there are more and more vertical applications, the interaction between applications is inevitable. The core business is extracted as an independent service, gradually forming a stable service center, so that the front-end applications can respond to the changing market demand more quickly. At this point, the distributed service framework (RPC) used to improve business reuse and integration is the key.
l flow computing architecture
When there are more and more services, capacity evaluation, waste of small service resources and other problems gradually appear. At this time, it is necessary to add a dispatching center to manage the cluster capacity in real time based on the access pressure to improve the cluster utilization. At this point, the resource scheduling and Governance Center (SOA) for improving machine utilization is the key
3, Zookeeper and Dubbo
•ZooKeeper
ZooKeeper is a distributed, open source distributed application coordination service. It is a software that provides consistency services for distributed applications. Its functions include configuration maintenance, domain name service, distributed synchronization, group service, etc.
•Dubbo
Dubbo is an open-source distributed service framework of Alibaba. Its biggest feature is that it is structured in a hierarchical way. This way can decouple (or loosen) the coupling between various layers. From the perspective of service model, Dubbo adopts a very simple model. Either the Provider provides services or the Consumer consumes services. Therefore, based on this, the two roles of service Provider and service Consumer can be abstracted
1. Install and start zookeeper as the registry
docker pull zookeeper
docker run --name zk -p 2181:2181 --restart always -d zookeeper
2. Authoring service providers
3. Writing service consumers
4. Integrate dubbo
<dependency> <groupId>com.alibaba.spring.boot</groupId> <artifactId>dubbo-spring-boot-starter</artifactId> <version>2.0.0</version> </dependency>
Take an example:
package com.xiaomeng.ticket.service; public interface TicketService { public String getTicket(); }
package com.xiaomeng.ticket.service; public interface TicketService { public String getTicket(); }
import com.alibaba.dubbo.config.annotation.Service; import org.springframework.stereotype.Component; //Technical exchange V:kaifazixun @Component @Service public class TicketServiceImpl implements TicketService { @Override public String getTicket() { return "<Mermaid"; } }
4, Spring Boot and Spring Cloud
Spring Cloud
Spring Cloud is a distributed overall solution. Spring Cloud provides a tool for developers to quickly build in distributed systems (configuration management, service discovery, fusing, routing, micro proxy, control bus, one-time token, global lock, leader election, distributed session, cluster status). Developers using Spring Cloud can quickly start services or build applications, and can quickly connect with cloud platform resources.
• five common components of SpringCloud distributed development
• service discovery - Netflix Eureka
• customer service end load balancing - Netflix Ribbon
• circuit breaker - Netflix Hystrix
• service gateway - Netflix Zuul
• distributed configuration - Spring Cloud Config
Microservices
Getting started with Spring Cloud
1. Create provider
2. Create consumer
3. Introducing Spring Cloud
4. Introducing Eureka registry
5. Introducing Ribbon for client load balancing
JAXB module is not loaded by default after JDK9 version, and dependency needs to be added manually
<!-- Manual loading JAXB modular --> <dependency> <groupId>javax.xml.bind</groupId> <artifactId>jaxb-api</artifactId></dependency> <dependency> <groupId>com.sun.xml.bind</groupId> <artifactId>jaxb-impl</artifactId> </dependency> <dependency> <groupId>org.glassfish.jaxb</groupId> <artifactId>jaxb-runtime</artifactId> </dependency> <dependency> <groupId>javax.activation</groupId> <artifactId>activation</artifactId> </dependency>
Implementation of UserController in SpringCloud:
@RestController Technical exchange V: kaifazixun public class UserController { @Autowired RestTemplate restTemplate; @GetMapping("/buyTicket") public String buyTicket(){ return restTemplate.getForObject("http://PROVIDER-TICKET/getTicket",String.class); } }
ConsumerUserApplication implementation:
@EnableDiscoveryClient //Enable discovery service @SpringBootApplication public class ConsumerUserApplication { public static void main(String[] args) { SpringApplication.run(ConsumerUserApplication.class, args); } @LoadBalanced //Using the load balancing mechanism @Bean public RestTemplate restTemplate(){ return new RestTemplate(); } }
Implementation of EurekaServerApplication:
import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; @EnableEurekaServer @SpringBootApplication public class EurekaServerApplication { public static void main(String[] args) { SpringApplication.run(EurekaServerApplication.class, args); } }
Implementation of providerticket:
import com.xiaomeng.providerticket.service.TicketService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; //Development technology exchange, +V:kaifazixun @RestController public class TicketController { @Autowired TicketService ticketService; @GetMapping("/getTicket") public String getTicket(){ return ticketService.getTicket(); } }
5, Dry goods sharing
Finally, Xiao Meng has many projects and often stays up late at night to work overtime. Some of my friends complained to me about the pressure of school and work.
I want to say: the world of adults is not easy. There is no need to complain and the job is done.
Recently, I have sorted out a lot of materials to help my friends with their interview and study. I need to collect them quickly!
Take it to learn. It's really not easy to organize. Like collecting and forwarding! It is my greatest support, respect!
Of course, there can also be technical exchange groups. How can we hold a group together for common progress?
Look at the last picture!
Click below to follow the pop-up official account map,
Reply: interview book
Not a comment area reply, not a comment area reply, not a comment area reply,
Data acquisition plus technology, click to follow 👇🏻👇🏻👇🏻