springcloud learning 1-- registry

Learn from the station b springcloud, now summarize the summary removal of a small error appearing in the video, some of the error-prone places were reminded
b outbound links: https://www.bilibili.com/video/av55304977

data link:
https://pan.baidu.com/s/1o0Aju3IydKA15Vo1pP4z5w
extraction code: 21ru

The next section link: https://blog.csdn.net/qq_40893824/article/details/103324622

The following is a summary of the contents of the parent pom pom file → file → sub-sub-project application → startup class

Implementation details:
1. Create a maven project:

Here Insert Picture Description

Click next → Finish to create success.

2. bottom right

click Enable Auto-Import, meaning the package is automatically imported meaning.

3. Open the project's pom files (also known as the parent pom file), then create some module module, they themselves have pom file (called sub-pom file), the child may inherit the parent pom pom file, not vice versa.

4. Write the arrow in FIG code (called a write dependencies), springcloud created, because a simple programming method is to introduce implementation details do dependent.
Behind a starter novice easily written start

	<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.2.RELEASE</version>
    </parent>

    <!-- springboot的依赖 -->
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId> <!-- 成为web环境 -->
        </dependency>
    </dependencies>

    <!-- springcloud的依赖 -->
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>Finchley.SR2</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
   

5. Create a sub-project eurekaserver

click next, fill in the name eurekaserver
after Finsih:

This creates a success

6. Fill in the dependent code in this project pom.xml:

	<dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
            <version>2.0.2.RELEASE</version>
        </dependency>
    </dependencies>

7. Create a profile application.yml


created after the successful entry into application.yml fill in the code:
the Register-with-Eureka: false #false said they did not register itself with the registry.
fetch-registry: false #false said he is the end registry, my duty is to maintain a service instance, you do not need to search services

server:
  port: 8761
eureka:
  client:
    register-with-eureka: false
    fetch-registry: false
    service-url: 
      defaultZone: http://localhost:8761/eureka/

8. Create a Startup categories:


Here Insert Picture Description
below fill in the name: EurekaServerApplication

enter EurekaServerApplication.java:

Fill:

package com.southwind;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;

@SpringBootApplication
@EnableEurekaServer
public class EurekaServerApplication {
    public static void main(String[] args) {
        SpringApplication.run(EurekaServerApplication.class,args);
    }
}

Start:


normal operation!
Enter http: // localhost: 8761 View:

this registry is set up.

The next section link: https://blog.csdn.net/qq_40893824/article/details/103324622

Published 42 original articles · won praise 2 · Views 1192

Guess you like

Origin blog.csdn.net/qq_40893824/article/details/103323782