Today, I’m going to document how to build a springCloud framework hand in hand.

Set up eureka service

The first step

Start by creating a SpringBoot service. I was too lazy to create my own, so I created the SpringBoot project online.

IO/start.spring. IO /

The download is a zip package, unzip it, and use the compiler IDEA to open the service.

The first one is the pom.xml file.

< the groupId > com. Blog < / groupId > < artifactId > eureka < / artifactId > < version > 0.0.1 - eureka - the SNAPSHOT < / version > <packaging>jar</packaging> <name>eureka</name> <description>eurekaforblog</description> <parent> <groupId>org.springframework.boot</groupId> The < artifactId > spring - the boot - starter - parent < / artifactId > < version > 1.5.1. RELEASE < / version > < relativePath / > <! -- lookup parent from repository --> </parent> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> < project. Reporting. OutputEncoding > utf-8 < / project. Reporting. OutputEncoding > < Java version > 1.8 < / Java version > <spring-cloud.version>Edgware.RELEASE</spring-cloud.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <! - introduction of eureka depend on - > < the dependency > < groupId > org. Springframework. Cloud < / groupId > <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> <! -- Introduce spring Cloud dependencies, not less, <dependency management > <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>Edgware.RELEASE</version> <type>pom</type>
    				<scope>import</scope>
    			</dependency>
    		</dependencies>
    	</dependencyManagement>
    </project>
Copy the code

As you can see, my springBoot version dependency is 1.5.1.RELEASE, and my springCloud version dependency is edgware. RELEASE. Dependencies of a series of plug-ins that cause springCloud to fail to be imported.

If you want to upgrade springCloud, please go to the Official website of Spring to find the adaptation version of springCloud and SpringBoot. I have checked it myself, but it is not always reliable. There are always problems, so I tried several times and finally produced the current version.

Second: the application.properties file

Image:

server.port: 1111
spring.application.name=eureka
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
eureka.server.enableSelfPreservation: falseEureka. Server. Renewal - percent - threshold = 0.45The default value is 60
#org.springframework.cloud.netflix.eureka.server.EurekaServerConfigBean.evictionIntervalTimerInMs
eureka.server.evictionIntervalTimerInMs=5000
eureka.client.serviceUrl.defaultZone=http://localhost:1111/eureka/
Copy the code

Third: eurekaApplication.java file

Image:

@enableEurekaserver // Declare that this is a Eureka service @springBootApplication public class EurekaApplication {public static void main(String[] args) { SpringApplication.run(EurekaApplication.class, args); }}Copy the code

After the three configuration files are modified, start the service.

Open the web page and type in the url: localhost:1111

If the access succeeds, the eureka server is successfully started.

Next article, building a Client for Eureka.