最新springboot2.0集成springcloud注册中心(第一章)

 这是我的新建的格式可供新手学习!

最新springboot2.0集成springcloud注册中心(第一章)_第1张图片

 

首先引入依赖 


  4.0.0
  cn.com.zrf
  springcloud-eureka
  0.0.1-SNAPSHOT
  

    org.springframework.boot
    spring-boot-starter-parent
    2.0.0.RELEASE
    
  
      
        UTF-8
        UTF-8
        1.8
        
        Finchley.RELEASE
    
  
  
		    org.springframework.boot
		    spring-boot-starter
		
		
		    org.springframework.boot
		    spring-boot-starter-test
		
		 
            org.springframework.boot
            spring-boot-starter-web
        
  
	
		
	
	    org.springframework.cloud
	    spring-cloud-starter-netflix-eureka-server
	
	

 
        
            
                org.springframework.cloud
                spring-cloud-dependencies
                ${spring-cloud.version}
                pom
                import
            
        
    

其次编写代码

package cn.com.zrf;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;

@EnableEurekaServer
@SpringBootApplication
public class EurekaServerApplication {
	public static void main(String[] args) {
		SpringApplication.run(EurekaServerApplication.class, args);
	}
}

 编写application.properties

#注册中心服务ID
spring.application.name=compute-server
#端口号
server.port=8888
eureka.instance.hostname=localhost
# eureka.client.registerWithEureka :表示是否将自己注册到Eureka Server,默认为true。
# 由于当前这个应用就是Eureka Server,故而设为false 
#不要向注册中心注册自己
eureka.client.register-with-eureka=false

#eureka.client.fetchRegistry :表示是否从Eureka Server获取注册信息,默认为true。因为这是一个单点的Eureka Server,
# 不需要同步其他的Eureka Server节点的数据,故而设为false
#禁止检索服务
eureka.client.fetch-registry=false
eureka.client.service-url.defaultZone=http://${eureka.instance.hostname}:${server.port}/eureka

接下来就能看到这样的页面就算成功啦,集成还是很简单的,哈哈

最新springboot2.0集成springcloud注册中心(第一章)_第2张图片

 

你可能感兴趣的:(java,java,springboot,springcloud)