springcloud eureka注册中心搭建
2024-09-07 06:55:33
环境描述
① jdk1.8
② idea
③ springcloud版本 Finchley.SR2
④ maven3.0+
导入jar包
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties> <parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.2.RELEASE</version>
</parent> <dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Finchley.SR2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement> <dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
</dependencies> <build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
<addResources>true</addResources>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
添加配置application.yml
server:
port: 8761
spring:
application:
name: smart-platform-eureka1
eureka:
instance:
hostname: localhost
client:
registerWithEureka: false
fetchRegistry: false
serviceUrl:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
server:
#eureka服务自我保护模式 默认是开启的
enable-self-preservation: false
#eureka服务 指定时间清理死掉的服务 默认60秒 单位毫秒
eviction-interval-timer-in-ms: 60000
编写eureka服务启动类
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; @SpringBootApplication
@EnableEurekaServer
public class Application {
public static void main( String[] args) throws Exception{
new SpringApplicationBuilder(Application.class).run(args);
}
}
效果展示(红色提示语是因为application.yml配置中将服务自我保护模式设置为了false)
最新文章
- python fork 用法
- jquery学习笔记---Dom操作
- [Linux] VIM 常用快捷键2
- 判断字符串中是否有SQL攻击代码
- 【阿里云产品公测】消息队列服务MQS使用分享
- [Git]更新远程代码到本地仓库
- poj 2485 (kruskal算法)
- OpenStreetMap数据清洗(SQL&;MonogoDB版本)
- 1013团队alpha冲刺日志集合帖
- SpringBoot cache-control 配置静态资源缓存 (以及其中的思考经历)
- 【学习】Linux Shell脚本编程
- C# -- 使用委托 delegate 执行异步操作
- html5滑动事件代码
- 使用 erlang OTP 模式编写非阻塞的 tcp 服务器(来自erlang wiki)
- org.apache.ibatis.builder.IncompleteElementException: Could not find result map java.util.HashMap
- (转)Java调用Weservice
- redis常用性能分析命令
- 【F12】Console命令,让js调试更简单
- MVC文件上传03-使用Request.Files上传多个文件
- IIS7设置IP地址和域名限制
热门文章
- js使用心得——避免全局变量冲突的小技巧
- LeetCode No.82,83,84
- Windows下的GUI 库
- 规范化开发和time相关模块
- oracle存储过程随笔
- $(document).ready()和window.onload方法
- SpringMVC学习笔记九:拦截器及拦截器的简单实用
- 内核融合:GPU深度学习的“加速神器”
- 从 ListView 到 RecyclerView 的用法浅析
- RHEL系统下安装atlassian-jira-5