Springboot-EurekaServer搭建问题
作者:互联网
最近需要搭建个注册中心,其中遇到几个问题记录一下:
首先再idea创建maven项目,接着
1.引入eureka依赖
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
<version>2.1.2.RELEASE</version>
</dependency>
2.增加启动类
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
@EnableEurekaServer
@SpringBootApplication
public class AppEureka {
public static void main(String[] args) {
SpringApplication.run(AppEureka.class,args);
}
}
3.增加配置文件application.yml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>eureka</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
<version>2.2.3.RELEASE</version>
</dependency>
</dependencies>
</project>
依赖大功告成了就要,启动报错如下
怀疑是版本问题更换版本,
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
<version>2.1.2.RELEASE</version>
启动,报错,看样子是缺少了com.google.code.gson包,引入
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.6</version>
</dependency>
大功告成,访问localhost:8100
标签:Springboot,netflix,springframework,eureka,EurekaServer,org,server,cloud,搭建 来源: https://blog.csdn.net/w1028556865/article/details/118567405