今天搭建了一下eureka的客户端配置,简单记录一下:
1.首先新建一个spring-boot项目,过程省略
2.之后引入jar包,pom文件中<dependencies>标签中加入
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter</artifactId>
<version>1.3.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka-server</artifactId>
<version>1.4.6.RELEASE</version>
</dependency>
pom中的parent被我改成了这个版本,用以解决搭建后的jar包冲突错误(nosuchmethodException 。。。。bulabula)
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
3.application.properties中添加配置
spring.application.name=spring-cloud-eureka
server.port=8000
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
eureka.client.healthcheck.enabled=true
eureka.client.serviceUrl.defaultZone=http://localhost:${server.port}/eureka/
这里没有
eureka.client.healthcheck.enabled=true
的话会报错::Parameter 3 of method eurekaRegistration EurekaClientAutoConfiguratio;
这条配置是:开启健康检查(需要spring-boot-starter-actuator依赖)。具体咋回事还没空研究。。留着慢慢看;
4.启动类增加 @EnableEurekaServer配置
@SpringBootApplication
@EnableEurekaServer
public class SpringCloudEurekaApplication {
public static void main(String[] args) {
SpringApplication.run(SpringCloudEurekaApplication.class, args);
}
}
5.启动成功后访问 :http://localhost:8000/即可:
以上;