[spring cloud collection, Java interview questions for junior programmers of the company

2, How Eureka works

3, Eureka environment construction

1. Create a new moudle

2. Change pom

3. Write yml

4. Startup class

5. Test

4, payment8001 registered in Eureka

1.pom add dependency

2. Change yml

3. Annotate the startup class

4. Test

5, order80 register in Eureka

The tests are as follows

1, What is Eureka?

=============

Eureka is the core and default registry component in Spring Cloud system. Its main function is to realize service governance through service registration and service discovery and manage many micro services in Spring Cloud.

**Say something: * * if spring cloud is a community and many micro services are residents in the community, Eureka is the community property. Whoever comes or goes should be notified to the property.

2, How Eureka works

=================

Eureka provides a server and a client. The server is the Eureka service registry. The client completes the registration and discovery of microservices to Eureka services. Both server and client are written in Java language.

dubbo is a micro service framework developed by Alibaba.

3, Eureka environment construction

============

The same old five steps!!

1. Create a new moudle

Not much: cloud Eureka server 7001

2. Change pom

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0"

         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <parent>

        <artifactId>cloud2020</artifactId>

        <groupId>com.li.springcloud</groupId>

        <version>1.0-SNAPSHOT</version>

    </parent>

    <modelVersion>4.0.0</modelVersion>



    <artifactId>cloud-eureka-server7001</artifactId>



    <dependencies>

        <!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-eureka-server -->

        <dependency>

            <groupId>org.springframework.cloud</groupId>

            <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>

        </dependency>



        <dependency>

            <groupId>com.atguigu.springcloud</groupId>

            <artifactId>cloud-api-commons</artifactId>

            <version>${project.version}</version>

        </dependency>



        <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web -->

        <dependency>

            <groupId>org.springframework.boot</groupId>

            <artifactId>spring-boot-starter-web</artifactId>

        </dependency>



        <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web  -->

        <dependency>

            <groupId>org.springframework.boot</groupId>

            <artifactId>spring-boot-starter-actuator</artifactId>

        </dependency>



        <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-devtools -->

        <dependency>

            <groupId>org.springframework.boot</groupId>

            <artifactId>spring-boot-devtools</artifactId>

            <scope>runtime</scope>

            <optional>true</optional>

        </dependency>



        <!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->

        <dependency>

            <groupId>org.projectlombok</groupId>

            <artifactId>lombok</artifactId>

        </dependency>



        <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-test -->

        <dependency>

            <groupId>org.springframework.boot</groupId>

            <artifactId>spring-boot-starter-test</artifactId>

            <scope>test</scope>

        </dependency>

        <dependency>

            <groupId>junit</groupId>

            <artifactId>junit</artifactId>

        </dependency>



    </dependencies>

</project> 

Observe more dependence than before

 <dependency>

            <groupId>org.springframework.cloud</groupId>

            <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>

        </dependency>

3. Write yml

Pay attention to understand the meaning of each line.

server:

  port: 7001



eureka:

  instance:

    hostname: localhost  #Instance name of eureka server

  client:

    register-with-eureka: false    #I don't register myself with the registry

    fetch-registry: false   #It means that it is the registry. Its responsibility is to maintain service instances and does not need to retrieve services

    service-url:

      defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka / # sets the address on which the query service and registration service interact with eureka server 

4. Startup class

Finally, let's put a wave of benefits out! I hope I can help you!

CodeChina open source project: [analysis of Java interview questions of front-line large manufacturers + core summary learning notes + latest explanation Video]

Thousands of people should remember: brush more questions!! Brush more questions!!

The algorithm was my hard wound before, but it took me a long time to make it up. The algorithm is the soul of the programmer!!!!

Space is limited, the following screenshots can only share some resources!!

(1) Multithreading (represented by multithreading here, in fact, a collection of notes on JAVA core architecture is compiled)

(2) Brush algorithm problems (and Zuo Shen's algorithm notes)

(3) Face to face classics + real problem analysis + corresponding relevant notes (very comprehensive)

(4) Video learning (part)

ps: video is a good choice when you feel unable to learn or tired

In fact, I can share all the above things for free if necessary

Come back, the algorithm is the soul of the programmer!!!!

Space is limited, the following screenshots can only share some resources!!

(1) Multithreading (represented by multithreading here, in fact, a collection of notes on JAVA core architecture is compiled)

[external chain picture transferring... (img-ZGl1dxPm-1630854334506)]

(2) Brush algorithm problems (and Zuo Shen's algorithm notes)

[external chain picture transferring... (img-htm9nhx4-163085434508)]

(3) Face to face classics + real problem analysis + corresponding relevant notes (very comprehensive)

[external chain pictures are being transferred... (img-a2xgiape-163085434510)]

(4) Video learning (part)

ps: video is a good choice when you feel unable to learn or tired

In fact, I can share all the above things for free if necessary

Here, the last sentence is: I wish you all a soft offer!!

Keywords: Java Back-end Interview Programmer RESTful

Added by AudiS2 on Sun, 05 Sep 2021 20:31:06 +0300