环境描述

① 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)

最新文章

  1. python fork 用法
  2. jquery学习笔记---Dom操作
  3. [Linux] VIM 常用快捷键2
  4. 判断字符串中是否有SQL攻击代码
  5. 【阿里云产品公测】消息队列服务MQS使用分享
  6. [Git]更新远程代码到本地仓库
  7. poj 2485 (kruskal算法)
  8. OpenStreetMap数据清洗(SQL&amp;MonogoDB版本)
  9. 1013团队alpha冲刺日志集合帖
  10. SpringBoot cache-control 配置静态资源缓存 (以及其中的思考经历)
  11. 【学习】Linux Shell脚本编程
  12. C# -- 使用委托 delegate 执行异步操作
  13. html5滑动事件代码
  14. 使用 erlang OTP 模式编写非阻塞的 tcp 服务器(来自erlang wiki)
  15. org.apache.ibatis.builder.IncompleteElementException: Could not find result map java.util.HashMap
  16. (转)Java调用Weservice
  17. redis常用性能分析命令
  18. 【F12】Console命令,让js调试更简单
  19. MVC文件上传03-使用Request.Files上传多个文件
  20. IIS7设置IP地址和域名限制

热门文章

  1. js使用心得——避免全局变量冲突的小技巧
  2. LeetCode No.82,83,84
  3. Windows下的GUI 库
  4. 规范化开发和time相关模块
  5. oracle存储过程随笔
  6. $(document).ready()和window.onload方法
  7. SpringMVC学习笔记九:拦截器及拦截器的简单实用
  8. 内核融合:GPU深度学习的“加速神器”
  9. 从 ListView 到 RecyclerView 的用法浅析
  10. RHEL系统下安装atlassian-jira-5