Spring Cloud Netflix—服务发现:Eureka
如何包含Eureka服务器
要在项目中包含Eureka服务器,请使用组org.springframework.cloud和工件idspring-cloud-starter-eureka-server的启动器。有关 使用当前的Spring Cloud发布列表设置构建系统的详细信息,请参阅Spring Cloud项目页面。
如何运行Eureka服务器
示例eureka服务器;
@SpringBootApplication
@EnableEurekaServer
public class Application {
public static void main(String[] args) {
new SpringApplicationBuilder(Application.class).web(true).run(args);
}
}
服务器具有一个带有UI的主页,并且根据/eureka/*下的正常Eureka功能的HTTP API端点。
提示由于Gradle的依赖关系解决规则和父母的bom功能缺乏,只要依靠spring-cloud-starter-eureka-server就可能导致应用程序启动失败。要解决这个问题,必须添加Spring Boot Gradle插件,并且必须导入Spring云启动器父母bom:
的build.gradle
buildscript {
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.3.5.RELEASE")
}
}
apply plugin: "spring-boot"
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:Brixton.RELEASE"
}
}
源码来源:http://minglisoft.cn/honghu/technology.html
