搭建Eureka服务注册中心
去到这个Spring的代码生成网站,网站貌似改版了,感觉以前的好看点儿
https://start.spring.io/
网站目前大概是这个样子的:
group和artifact随意,主要是上面的依赖选择,输入Eureka,选择Eureka Server即可,如果要加验证的话,可以加上Security模块
然后生成工程:
然后倒入Eclipse中【其实在Eclipse中安装相关插件也可以建立SpringBoot的工程,建议可以用Spring的STS】
配置一下配置文件:
#spring:
# security:
# user:
# name: admin
# password: pwd
server:
port: 8761
eureka:
instance:
hostname: localhost
client:
register-with-eureka: false
fetch-registry: false
service-url:
defaultZone: http://${eureka.instance.hostname}:${server.port}/
在启动类上加上:@EnableEurekaServer
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
@SpringBootApplication
@EnableEurekaServer
public class EurekaDemoApplication {
public static void main(String[] args) {
SpringApplication.run(EurekaDemoApplication.class, args);
}
}
然后启动访问:localhost:8761/
********************************* 不积跬步无以至千里,不积小流无以成江海 *********************************
还没有评论,来说两句吧...