머리말
Eureka는 서비스 발견 및 등록 프레임 워크입니다. 보다 구체적으로, 우리는 그것을 Eureka-Server (Service Discovery)와 Eureka-Client (서비스 등록)의 두 가지 유형으로 나눌 수 있습니다. 이번에는 Spring-Cloud의 시작으로 Eureka-Server (Service Discovery)를위한 프로젝트를 구축 할 것입니다.
오픈 소스 주소 : https://github.com/bigbeef
프로젝트 구조
모든 사람은 Maven의 구조를 알아야합니다 (명확하지 않으면 추가해야합니다. Baidu의 Maven에 대한 수많은 기사가 있습니다). 이 키 파일의 구성을 살펴 보겠습니다.
코드 쓰기
CPPBA-Spring-Cloud> pom.xml
<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/0.0.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd "> <modelversion> 4.0.0 </modelversion> <groupid> com.cppba </groupid> <artifactid> cppba-spring-cloud </artifactid> <0.0 </version> <pomating> pomaging> pomaging> <이름> $ {project.artifactid} </name> <부모> <groupid> org.springframework.boot </groupid> <artifactid> Spring-Boot-Starter-Parent </artifactid> <버전> 1.5.5.5.Release </version> </parent> <specties> <project.build.sourceencoding> utf-8 </project.build.sourceencoding> <java.version> 1.8 </java.version> <spring-cloud.version> dalston.sr2 </spring-cloud.version> </properties> <pectionalmanagement> <peciplency> <groupid> org.springframework.cloud </groupid> <artifactid> spring-cloud-dependencies </artifactid> <버전> $ {spring-cloud.version} </version> <type> pom </type> <scope> import </scope> </dependency> </fectionency> </dependencymanagement> <모듈> CPPBA-Spring-Cloud-Eureka-Server </module> </modules> </project>CPPBA-Spring-Cloud-Eureka-Server> pom.xml
<? 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.xsd"> <modeversion> 4.0.0 </modelversion> <artifactid> cppba-spring-cloud-eureca-eerureca-serifactid <packaging> jar </packaging> <name> $ {project.artifactid} </name> <부모> <groupid> com.cppba </groupid> <artifactid> cppba-spring-cloud </artifactid> <bersion> 1.0.0 </version> </parent> <pectionency> <groupid> org.spramframeworg.scromwork.scromwerg.scromwerg. <아티 팩트> 스프링 클라우드 스타터-유레 키르-서버 </artifactid> </fectionement> </fectencies> <finalname> $ {project.name} </finalName> <플러그인> <!-포장 실행 jar-> <Plugin> <GroupId> org.springframewort </groupId> <Artifactid> Spring-Boot-Maven-Plugin </artifactid> </plugin> </plugins> </build> </project>SpringCloudeureKaserVerpplication.java
패키지 com.cppba; import org.springframework.boot.springApplication; import org.springframework.boot.autoconfigure.springbootApplication; import org.springframework.cloud.netflix.eureka.server.enableeurekaserver@sprighteponcationkaserkaserkaserkaStrycourtickasekasekaserKASCARSTRYC SpringCloudeureKaserVerApplication {public static void main (String [] args) {springApplication.Run (SpringCloudEureKaserApplication.class, args); }}application.properties
Server.port = 8761eureka.instance.hostname = Eureka-servereureka.client.registerwitheureka = falseureka.client.fetchregistry = falseeureka.client.serviceurl.defaultzone = http : // $ {eureka.instance.hostname} : $ {port.port.port.port.port.port.port.프로젝트가 완료되었습니다
프로젝트를 시작하십시오
SpringCloudeureKaserVerpplication에서 주요 방법을 시작하고 액세스 http://127.0.0.1:8761
이 시점에서 Eureka-Server (Service Discovery) 프로젝트가 성공적으로 구축되었습니다.
위는이 기사의 모든 내용입니다. 모든 사람의 학습에 도움이되기를 바랍니다. 모든 사람이 wulin.com을 더 지원하기를 바랍니다.