Springcloud学习(一)基于eureka注册中心的搭建

基于eureka注册中心的搭建

源码地址https://github.com/Jacwo/eure... 欢迎start 鼓励一下

  • 使用idea新建一个maven项目 可以使用spring Initializr
  • 替换pom.xml


    4.0.0
    
        org.springframework.boot
        spring-boot-starter-parent
        1.5.9.RELEASE
         
    
    com.yyl
    eureka-server
    0.0.1-SNAPSHOT
    eureka-server
    Demo project for Spring Boot
    
        
            org.springframework.cloud
            spring-cloud-netflix-eureka-server
            1.3.5.RELEASE
        
    

    
        
            
                org.springframework.cloud
                spring-cloud-dependencies
                Camden.SR3
                pom
                import
            
            
                org.springframework.cloud
                spring-cloud-config-server
            
            
                org.springframework.cloud
                spring-cloud-starter-eureka-server
            
            
            
                org.springframework.boot
                spring-boot-starter-actuator
            
        
    

    
        
            
                org.springframework.boot
                spring-boot-maven-plugin
            
            
                org.apache.maven.plugins
                maven-compiler-plugin
                
                    1.8
                    1.8
                
            
        
    

  • 编写启动类
package com.yyl.eurekaserver;

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

/**
 * @author yangyuanliang
 */
@SpringBootApplication
@EnableEurekaServer
public class EurekaServerApplication {

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

}
  • 配置application.properties
server.port=8672
eureka.instance.hostname=localhost
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
eureka.client.serviceUrl.defaultZone=http://${eureka.instance.hostname}:${server.port}/eureka/
  • 启动 mvn spring-boot:run
  • 测试 打开浏览器输入 http://localhost:8672


你可能感兴趣的:(springcloud)