mysql也能注册到eureka_为什么我的服务提供者和消费者都注册不到eureka注册中心?...
今天剛開始學習spring cloud,在試著將provider和consumer注冊到eureka-server的時候,發現沒有注冊到。
這是我的項目目錄結構:
這是我的spring boot版本:
這是我的spring cloud版本:
這是spring-cloud-eureka的依賴:
我的eureka可以正常訪問:
下面是spring-cloud-provider的依賴:
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
org.springframework.boot
spring-boot-starter-parent
2.0.6.RELEASE
com.yostar.demo
spring-cloud-provider
0.0.1-SNAPSHOT
spring-cloud-provider
Demo project for Spring Boot
1.8
Finchley.SR2
org.springframework.boot
spring-boot-starter-jdbc
org.springframework.boot
spring-boot-starter-web
org.mybatis.spring.boot
mybatis-spring-boot-starter
2.1.1
mysql
mysql-connector-java
runtime
org.springframework.boot
spring-boot-starter-test
test
tk.mybatis
mapper-spring-boot-starter
2.1.5
org.springframework.cloud
spring-cloud-starter-config
org.springframework.cloud
spring-cloud-netflix-eureka-client
org.springframework.cloud
spring-cloud-dependencies
${spring-cloud.version}
pom
import
org.springframework.boot
spring-boot-maven-plugin
這是我spring-cloud-provider的application.properties文件:
server.port=8081
# 作為微服務名稱
spring.application.name=service-provider
# 數據庫連接信息
spring.datasource.url=jdbc:mysql:///mybatis?serverTimezone=UTC
spring.datasource.username=root
spring.datasource.password=yostar
# MyBatis信息
mybatis.type-aliases-package=com.yostar.pojo
# Eureka信息
eureka.client.service-url.defaultZone=http://localhost:8761/eureka/
我也在SpringCloudProviderApplication引導文件上加入了@EnableDiscoryClient:
但是重啟以后,刷新eureka,在Instances currently registered with Eureka這里依然是空
請問這是為什么?是我還欠缺了什么東西嗎?求指教,謝謝!
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的mysql也能注册到eureka_为什么我的服务提供者和消费者都注册不到eureka注册中心?...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python中uniform(a、b)_
- 下一篇: mysql grant教程_MySQL如