열기:
이전 SpringBoot를 H2 메모리 데이터베이스에 통합하여 단위 테스트 및 데이터베이스 독립적 데이터베이스가 제공하는 RESTFUL 서비스를 Spring Cloud의 Eureka Server에 등록합니다.
1. 유레카 클라이언트를 소개합니다
</dependencies> <pectionement> <groupId> org.springframework.cloud </groupId> <artifactid> Spring-Cloud-Starter-Eureka </artifactid> </dependency> </dependency> </feenceMencies> <fexendenceManagement> <pectionmies> <groupDed> org.spramwork.springwork.scringwork.scringwork.springwork.sprongroud. <아티 팩트> 스프링-클라우드-의존성 </artifactid> version> camden.sr3 </version> <type> pom </type> <copo> 가져 오기 </scope> </fectionency> </fectionements> </fectionencyManagement>
2. 구성 파일을 추가하십시오
# 스프링 부팅 서비스의 응용 프로그램 이름은 Eureka Server Spring.application.name = SpringBoot-H2 Eureka.instance.prefer-IP-Address = True # Eureka Server 등록 서비스의 주소는 Eureka.client에 등록되어 있습니다 .Service-url.DefaultZone = http : 8761/eureka.
3. 유레카 클라이언트 지원을 켜십시오
패키지 com.chhliu.springboot.h2; org.springframework.boot.springApplication import; org.springframework.boot.autoconfigure.springbootapplication import; org.springframework.cloud.netflix.eureka.enableeurekaclient; @SpringBootApplication @enableEureKaclient Public Class SpringBooth2application {public static void main (String [] args) {springApplication.run (springbooth2application.class, args); }}4. 스프링 부트 서비스를 시작하고 확인하십시오
위의 단계를 통해 Spring Boot Service를 Eureka Server에 등록했습니다!
5. 가능한 문제
서비스 등록 프로세스 중에 연결 거부 된 예외가 다음과 같이 발견됩니다.
다음 매핑 관계가 호스트 파일에 추가되지 않을 수 있습니다.
127.0.0.1 LOACLHOST
위는이 기사의 모든 내용입니다. 모든 사람의 학습에 도움이되기를 바랍니다. 모든 사람이 wulin.com을 더 지원하기를 바랍니다.