新建一个springboot项目 registry
添加依赖
<!--微服务依赖(服务中心与服务都需要)-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
在启动类添加注解
@SpringBootApplication
@EnableEurekaServer // 启用Eureka服务
public class RegistryApplication {
private static final Logger log = LoggerFactory.getLogger(RegistryApplication.class);
private final Environment env;
public RegistryApplication(Environment env) {
this.env = env;
}
/**
* Main method, used to run the application.
*
* @param args the command line arguments
*/
public static void main(String[] args) {
SpringApplication app = new SpringApplication(RegistryApplication.class);
Environment env = app.run(args).<