Subscribe to the column development tool IDEA, development technology Spring Cloud
I learn from the blog.csdn.net/sky78690566…
Some articles by Sky786905664
Create a Maven project first, then remove the SRC directory.
Create a new module, which is a spring Boot project:
The procedure is as follows:
Items to be checked are shown in the red box:
My project name is: Eureka-server, directory structure is as follows:
After the creation succeeds, the dependencies are as follows:
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
Copy the code
The version number is as follows: in particular, there is a problem with the unkown error that cannot be downloaded from this version
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Copy the code
The @enableeurekaserver annotation on the startup class identifies the registry
@SpringBootApplication
@EnableEurekaServer
public class EurekaServerApplication {
public static void main(String[] args){ SpringApplication.run(EurekaServerApplication.class, args); }}Copy the code
The configuration file is as follows:
server.port=8081Hostname =localhost #Eureka is for the registry, whether you need to register yourself in the registry (defaulttrue)
eureka.client.fetch-registry=false#Erueka is for the registry and does not need to retrieve service information; (Indicates whether to obtain registration information from Eureka Server. The default value istrue. eureka.client.register-with-eureka=false
eureka.client.serviceUrl.defaultZone=http://${eureka.instance.hostname}:${server.port}/eure
Copy the code
Startup results:
Visit http://localhost:8081/
Code cloud address: gitee.com/hjc2/spring…