zuul 404

作者: IT宝哥哥 | 来源:发表于2020-04-12 17:22 被阅读0次
    1. 项目结构:
      zuul + eureka 构建的微服务
    2. 配置:
    //zuul网关
    server:
      port: 10010
    spring:
      application:
        name: leyou-gateway
    eureka:
      client:
        service-url:
          defaultZone: http://localhost:10086/eureka
        registry-fetch-interval-seconds: 5
    zuul:
      prefix: /api
      routes:
        item-service: /item/**
        search-service: /search/**
        test-service: /test/**
    debug: true
    
    //eureka
    server:
      port: 10086
      connection-timeout: 10000
    spring:
      application:
        name: leyou-registry
    eureka:
      client:
        service-url:
          defaultZone: http://localhost:10086/eureka
        register-with-eureka: false #面板是否显示eureka自己
        fetch-registry: false #是否拉去微服务列表
      server:
        enable-self-preservation: true
        eviction-interval-timer-in-ms: 10000
    debug: true
    
    //item-service
    server:
      port: 8081
      connection-timeout: 10000
    spring:
      application:
        name: item-service
      datasource:
        url: jdbc:mysql:///leyou
        username: root
        password: rootroot
    eureka:
      client:
        service-url:
          defaultZone: http://localhost:10086/eureka
    mybatis:
      type-aliases-package: com.leyou.item.pojo
    
    //test-service
    server:
      port: 8085
    spring:
      application:
        name: test-service
    eureka:
      client:
        service-url:
          defaultZone: http://localhost:10086/eureka
    
    服务已经启动
    1. 服务都启动后,item下的controller可以访问,但是test下的无法访问,已配置好nginx,且控制台无报错。
      item-server:http://api.leyou.com/api/itemXXX 可以访问
      test-server: http://api.leyou.com/api/testXXX 不可访问
      最终发现:
      http://api.leyou.com/api/item/category/list?pid=0 可以访问
      http://api.leyou.com/api/test-service/test 不可访问
      http://api.leyou.com/api/item-service/item/category/list?pid=0 不可访问
      不知道是什么原因,两个service几乎是相同的配置。

    相关文章

      网友评论

          本文标题:zuul 404

          本文链接:https://www.haomeiwen.com/subject/zkrbmhtx.html