euraka-server
1 导入 依赖
ext {
springCloudVersion = 'Finchley.M2'
}
dependencies {
compile('org.springframework.cloud:spring-cloud-starter-netflix-eureka-server')
testCompile('org.springframework.boot:spring-boot-starter-test')
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
2 配置 yml
server:
port: 8888
eureka:
instance:
hostname: localhost
client:
registerWithEureka: false
fetchRegistry: false
serviceUrl:
defaultZone: http:
在启动类上标明 @EnableEurekaServer
@SpringBootApplication
@EnableEurekaServer
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
euraka-client
1 导入 依赖
ext {
springCloudVersion = 'Finchley.M2'
}
dependencies {
compile('org.springframework.cloud:spring-cloud-starter-netflix-eureka-client')
testCompile('org.springframework.boot:spring-boot-starter-test')
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
2 配置 yml
spring:
application:
name: micro-weather-eureka-client
# euraka 客户端实例
eureka:
client:
serviceUrl:
defaultZone: http:
# euraka server路径
在启动类上标明 @EnableDiscoveryClient
@SpringBootApplication
@EnableDiscoveryClient
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}