开篇:
我们将前面的springboot整合h2内存数据库,实现单元测试与数据库无关性提供的restful服务注册到spring cloud的eureka server上。
一、引入eureka的client
?
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
</dependencies>
<dependency>
<groupid>org.springframework.cloud</groupid>
<artifactid>spring-cloud-starter-eureka</artifactid>
</dependency>
</dependencies>
<dependencymanagement>
<dependencies>
<dependency>
<groupid>org.springframework.cloud</groupid>
<artifactid>spring-cloud-dependencies</artifactid>
<version>camden.sr3</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencymanagement>
|
二、添加配置文件
?
|
1
2
3
4
5
|
# spring boot服务注册到eureka server上的应用名称
spring.application.name=springboot-h2
eureka.instance.prefer-ip-address=true
# eureka server注册服务的地址
eureka.client.service-url.defaultzone=http://localhost:8761/eureka
|
三、开启eureka client支持
?
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
package com.chhliu.springboot.h2;
import 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);
}
}
|
四、启动spring boot服务并验证
通过上面几个步骤,说明我们已经将spring boot的服务注册到了eureka server上了!
五、可能出现的问题
如果在服务注册的过程中,发现connection refused异常,如下:
有可能是hosts文件中没有加入如下映射关系
127.0.0.1 loaclhost
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持快网idc。
原文链接:http://blog.csdn.net/liuchuanhong1/article/details/54666777
相关文章
猜你喜欢
- ASP.NET自助建站系统中如何实现多语言支持? 2025-06-10
- 64M VPS建站:如何选择最适合的网站建设平台? 2025-06-10
- ASP.NET本地开发时常见的配置错误及解决方法? 2025-06-10
- ASP.NET自助建站系统的数据库备份与恢复操作指南 2025-06-10
- 个人网站服务器域名解析设置指南:从购买到绑定全流程 2025-06-10
TA的动态
- 2025-07-10 怎样使用阿里云的安全工具进行服务器漏洞扫描和修复?
- 2025-07-10 怎样使用命令行工具优化Linux云服务器的Ping性能?
- 2025-07-10 怎样使用Xshell连接华为云服务器,实现高效远程管理?
- 2025-07-10 怎样利用云服务器D盘搭建稳定、高效的网站托管环境?
- 2025-07-10 怎样使用阿里云的安全组功能来增强服务器防火墙的安全性?
快网idc优惠网
QQ交流群
您的支持,是我们最大的动力!
热门文章
-
2025-05-29 46
-
2025-05-25 34
-
2025-05-25 58
-
CentOS 5.5使用yum来安装LAMP(php运行环境)
2025-05-27 99 -
2025-05-29 24
热门评论



