场景
- spring-cloud选用了erueka做注册中心,启动项目后无法进入erueka的管理界面
- 具体的做法
- 创建spring-boot的module
- 引入spring-cloud的依赖
- spring-cloud-starter-netflix-eureka-server
- 引入管理spring-cloud的依赖 spring-cloud-dependencies
pom.xml配置
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>Hoxton.SR3</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
application.properties
server.port=9112
eureka.instance.hostname=localhost
# 避免向自己注册自己
eureka.client.register-with-eureka=false
# 不去搜索其他的服务
eureka.client.fetch-registry=false
server.servlet.context-path=/
#是否优先从文件系统加载template
spring.freemarker.prefer-file-system-access=false
# 指定注册中心的位置
eureka.client.service-url.defaultZone=http://${eureka.instance.hostname}:${server.port}/eureka/
解决
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/c2b9d3acb4dd82f295ade2ed3e600007.png)