demo案例application.yml:
spring:
application:
name: test-service
datasource:
url: jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf-8&useSSL=false
username: root
password: root
server:
port: 9999
mybatis:
mapperLocations: classpath*:/mapper/*.xml
configuration:
mapUnderscoreToCamelCase: true
management:
port: 8081
security:
enabled: true
feign:
hystrix:
enabled: true
security:
basic:
enabled: false
ignored: /v2/api-docs
eureka:
instance:
preferIpAddress: true
leaseRenewalIntervalInSeconds: 1
leaseExpirationDurationInSeconds: 3
client:
serviceUrl:
defaultZone: ${EUREKA_DEFAULT_ZONE:http://localhost:8000/eureka/}
docker-compose.yml配置:
version: "3"
services:
zookeeper-0:
container_name: zookeeper-0
image: registry.saas.hand-china.com/tools/zookeeper:3.4.10
hostname: zookeeper-0
environment:
- ZK_REPLICAS=1
- ZK_HEAP_SIZE=2G
- ZK_TICK_TIME=2000
- ZK_INIT_LIMIT=10
- ZK_SYNC_LIMIT=5
- ZK_MAX_CLIENT_CNXNS=60
- ZK_SNAP_RETAIN_COUNT=3
- ZK_PURGE_INTERVAL=1
- ZK_LOG_LEVEL=INFO
- ZK_CLIENT_PORT=2181
- ZK_SERVER_PORT=2888
- ZK_ELECTION_PORT=3888
ports:
- "2181:2181"
- "2888:2888"
- "3888:3888"
command:
- sh
- -c
- zkGenConfig.sh && exec zkServer.sh start-foreground
volumes:
- "/home/guoqingdeng/Desktop/docker-share/kafka/zk:/var/lib/zookeeper"
kafka-0:
container_name: kafka-0
image: registry.saas.hand-china.com/tools/kafka:1.0.0
hostname: kafka-0
depends_on:
- zookeeper-0
links:
- zookeeper-0
ports:
- "9092:9092"
command:
- sh
- -c
- "/opt/kafka/bin/kafka-server-start.sh config/server.properties \
--override zookeeper.connect=zookeeper-0:2181 \
--override log.dirs=/opt/kafka/data/logs \
--override broker.id=0 "
volumes:
- "/home/guoqingdeng/Desktop/docker-share/kafka/kafka:/opt/kafka/data"
redis:
container_name: redis
image: hub.c.163.com/library/redis:latest
ports:
- "6379:6379"
mysql:
container_name: mysql
image: registry.cn-hangzhou.aliyuncs.com/choerodon-tools/mysql:5.7.17
hostname: mysql
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: root
volumes:
- /home/guoqingdeng/Desktop/docker-share/mysql/mysql_data:/var/lib/mysql
- /home/guoqingdeng/Desktop/docker-share/mysql/mysql_db.cnf:/etc/mysql/conf.d/mysql_db.cnf
expose:
- "3306"
phpadmin:
container_name: phpadmin
image: registry.saas.hand-china.com/tools/phpmyadmin
ports:
- "8888:80" # 80端口方便浏览器直接访问
environment:
PMA_ARBITRARY: 1 # 用于开启phpadmin关于可否输入host的设置
eureka-server:
container_name: eureka-server
hostname: eureka-server
image: registry.cn-shanghai.aliyuncs.com/choerodon/eureka-server:0.5.0
ports:
- "8000:8000"
links:
- kafka-0
environment:
- spring.kafka.bootstrap-servers=kafka-0:9092
- eureka.client.serviceUrl.defaultZone=http://127.0.0.1:8000/eureka/
- eureka.client.register-with-eureka=false
- eureka.client.fetch-registry=false
- hystrix.stream.queue.enabled=false
- spring.cloud.bus.enabled=false
- spring.sleuth.stream.enabled=false
expose:
- "8000"
api-gateway:
container_name: api-gateway
image: registry.cn-shanghai.aliyuncs.com/choerodon/api-gateway:0.5.0
links:
- eureka-server
depends_on:
- eureka-server
ports:
- "8080:8080"
environment:
- eureka.client.serviceUrl.defaultZone=http://eureka-server:8000/eureka/
- hystrix.stream.queue.enabled=false
- spring.cloud.bus.enabled=false
- spring.sleuth.stream.enabled=false
expose:
- "8080"
gateway-helper:
container_name: gateway-helper
image: registry.cn-shanghai.aliyuncs.com/choerodon/gateway-helper:0.5.0
depends_on:
- eureka-server
- mysql
links:
- eureka-server
- mysql
ports:
- "9180:9180"
environment:
- eureka.client.serviceUrl.defaultZone=http://eureka-server:8000/eureka/
- spring.datasource.url=jdbc:mysql://mysql/iam_service?useUnicode=true&characterEncoding=utf-8&useSSL=false
- spring.datasource.username=root
- spring.datasource.password=root
- hystrix.stream.queue.enabled=false
- spring.cloud.bus.enabled=false
- spring.sleuth.stream.enabled=false
iam-service:
container_name: iam-service
image: registry.cn-shanghai.aliyuncs.com/choerodon/iam-service:0.5.0
depends_on:
- eureka-server
- mysql
- kafka-0
links:
- eureka-server
- mysql
- kafka-0
ports:
- "8030:8030"
environment:
- eureka.client.serviceUrl.defaultZone=http://eureka-server:8000/eureka/
- spring.kafka.bootstrap-servers=kafka-0:9092
- spring.datasource.url=jdbc:mysql://mysql/iam_service?useUnicode=true&characterEncoding=utf-8&useSSL=false
- spring.datasource.username=root
- spring.datasource.password=root
- hystrix.stream.queue.enabled=false
- spring.cloud.bus.enabled=false
- spring.sleuth.stream.enabled=false
manager-service:
container_name: manager-service
image: registry.cn-shanghai.aliyuncs.com/choerodon/manager-service:0.5.0
depends_on:
- eureka-server
- mysql
- kafka-0
links:
- eureka-server
- mysql
- kafka-0
ports:
- "8963:8963"
environment:
- spring.kafka.bootstrap-servers=kafka-0:9092
- eureka.client.serviceUrl.defaultZone=http://eureka-server:8000/eureka/
- spring.datasource.url=jdbc:mysql://mysql/manager_service?useUnicode=true&characterEncoding=utf-8&useSSL=false
- spring.datasource.username=root
- spring.datasource.password=root
- hystrix.stream.queue.enabled=false
- spring.cloud.bus.enabled=false
- spring.sleuth.stream.enabled=false
oauth-server:
container_name: oauth-server
image: registry.cn-shanghai.aliyuncs.com/choerodon/oauth-server:0.5.0
depends_on:
- eureka-server
- mysql
links:
- eureka-server
- mysql
ports:
- "8020:8020"
environment:
- eureka.client.serviceUrl.defaultZone=http://eureka-server:8000/eureka/
- spring.datasource.username=root
- spring.datasource.url=jdbc:mysql://mysql/iam_service?useUnicode=true&characterEncoding=utf-8&useSSL=false
- spring.datasource.password=root
- hystrix.stream.queue.enabled=false
- spring.cloud.bus.enabled=false
- spring.sleuth.stream.enabled=false
本地环境系统为Linux,首先docker-compose启动相关组件容器,此处正常,然后idea中启动demo案例代码,此处基本正常,访问http://localhost:8963/swagger-ui.html通过swagger方式查看demo相关服务及api,如下:
如上图,此处应该也是正常的
相关操作步骤:
- swagger中调用查询所有用户的api接口,已认证过,结果如下图,无数据返回
这个api接口我经过其他方式测试是可以拿到数据的,而且我的数据库表也是有数据的。
上述的问题点应该在于网关api-gateway没正确调用到demo案例的服务资源接口,麻烦相关研发人员给瞅瞅,看看我这里是哪有问题,如果是配置的问题,请正确贴出来哈,谢谢!