本地开发demo案例连接远程服务器,zk服务连接问题

  • Linux(Centos)服务器通过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:
          - "/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:
          - "/docker-share/kafka/kafka:/opt/kafka/data"
        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:
            - /docker-share/mysql/mysql_data:/var/lib/mysql
            - /docker-share/mysql/mysql_db.cnf:/etc/mysql/conf.d/mysql_db.cnf
          expose:
          - "3306"
        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:
          - zuul.routes.test.path=/test/** # 新增自定义服务时需要添加zuul.routes.服务名.path/serviceId这两个配置
          - zuul.routes.test.serviceId=test-service
          - 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:
          - zuul.routes.test.path=/test/** # 新增自定义服务时需要添加zuul.routes.服务名.path/serviceId这两个配置
          - zuul.routes.test.serviceId=test-service
          - 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
    

如上,可正常启动。

  • 本地idea运行案例,相关配置如下

      spring:
        application:
          name: test-service
        datasource:
          url: jdbc:mysql://172.20.10.10:3306/test?useUnicode=true&characterEncoding=utf-8&useSSL=false
          username: root
          password: root
        kafka:
          bootstrap-servers: 172.20.10.10:9092
      server:
        port: 8080
      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: 10
            leaseExpirationDurationInSeconds: 30
          client:
            serviceUrl:
              defaultZone: ${EUREKA_DEFAULT_ZONE:http://172.20.10.10:8000/eureka/}
    

启动运行demo,报错如下:

2018-06-20 15:08:56.711  INFO [test-service,,,] 29337 --- [localhost:2181)] org.apache.zookeeper.ClientCnxn          : Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
2018-06-20 15:08:56.712  WARN [test-service,,,] 29337 --- [localhost:2181)] org.apache.zookeeper.ClientCnxn          : Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect

java.net.ConnectException: 拒绝连接
	at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) ~[na:1.8.0_151]
	at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717) ~[na:1.8.0_151]
	at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:361) ~[zookeeper-3.4.8.jar:3.4.8--1]
	at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1141) ~[zookeeper-3.4.8.jar:3.4.8--1]

2018-06-20 15:08:57.813  INFO [test-service,,,] 29337 --- [localhost:2181)] org.apache.zookeeper.ClientCnxn          : Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
2018-06-20 15:08:57.813  WARN [test-service,,,] 29337 --- [localhost:2181)] org.apache.zookeeper.ClientCnxn          : Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect

java.net.ConnectException: 拒绝连接
	at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) ~[na:1.8.0_151]
	at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717) ~[na:1.8.0_151]
	at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:361) ~[zookeeper-3.4.8.jar:3.4.8--1]
	at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1141) ~[zookeeper-3.4.8.jar:3.4.8--1]

2018-06-20 15:08:57.918  INFO [test-service,,,] 29337 --- [           main] org.apache.zookeeper.ZooKeeper           : Session: 0x0 closed
2018-06-20 15:08:57.918  INFO [test-service,,,] 29337 --- [ain-EventThread] org.apache.zookeeper.ClientCnxn          : EventThread shut down for session: 0x0
2018-06-20 15:08:57.919  WARN [test-service,,,] 29337 --- [           main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Failed to start bean 'outputBindingLifecycle'; nested exception is org.springframework.cloud.stream.binder.BinderException: Exception thrown while building outbound endpoint
2018-06-20 15:08:57.924  INFO [test-service,,,] 29337 --- [           main] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@6e605c34: startup date [Wed Jun 20 15:08:47 CST 2018]; parent: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@4f824872
2018-06-20 15:08:57.927  INFO [test-service,,,] 29337 --- [           main] o.s.c.n.e.s.EurekaServiceRegistry        : Unregistering application test-service with eureka with status DOWN
2018-06-20 15:08:57.927  WARN [test-service,,,] 29337 --- [           main] com.netflix.discovery.DiscoveryClient    : Saw local status change event StatusChangeEvent [timestamp=1529478537927, current=DOWN, previous=UP]
2018-06-20 15:08:57.927  INFO [test-service,,,] 29337 --- [           main] com.netflix.discovery.DiscoveryClient    : Shutting down DiscoveryClient ...
2018-06-20 15:08:57.927  INFO [test-service,,,] 29337 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_TEST-SERVICE/172.20.10.5:test-service:8080: registering service...
2018-06-20 15:08:57.929  INFO [test-service,,,] 29337 --- [           main] com.netflix.discovery.DiscoveryClient    : Unregistering ...
2018-06-20 15:08:57.946  INFO [test-service,,,] 29337 --- [           main] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_TEST-SERVICE/172.20.10.5:test-service:8080 - deregister  status: 200
2018-06-20 15:08:57.950  INFO [test-service,,,] 29337 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_TEST-SERVICE/172.20.10.5:test-service:8080 - registration status: 204
2018-06-20 15:08:57.955  INFO [test-service,,,] 29337 --- [           main] com.netflix.discovery.DiscoveryClient    : Completed shut down of DiscoveryClient
2018-06-20 15:08:57.957  INFO [test-service,,,] 29337 --- [           main] o.s.s.c.ThreadPoolTaskScheduler          : Shutting down ExecutorService 'taskScheduler'
2018-06-20 15:08:57.958  INFO [test-service,,,] 29337 --- [           main] o.s.i.monitor.IntegrationMBeanExporter   : Unregistering JMX-exposed beans on shutdown
2018-06-20 15:08:57.958  INFO [test-service,,,] 29337 --- [           main] o.s.i.monitor.IntegrationMBeanExporter   : Unregistering JMX-exposed beans
2018-06-20 15:08:57.958  INFO [test-service,,,] 29337 --- [           main] o.s.i.monitor.IntegrationMBeanExporter   : Summary on shutdown: springCloudBusOutput
2018-06-20 15:08:57.958  INFO [test-service,,,] 29337 --- [           main] o.s.i.monitor.IntegrationMBeanExporter   : Summary on shutdown: sleuth
2018-06-20 15:08:57.958  INFO [test-service,,,] 29337 --- [           main] o.s.i.monitor.IntegrationMBeanExporter   : Summary on shutdown: nullChannel
2018-06-20 15:08:57.958  INFO [test-service,,,] 29337 --- [           main] o.s.i.monitor.IntegrationMBeanExporter   : Summary on shutdown: springCloudBusInput
2018-06-20 15:08:57.958  INFO [test-service,,,] 29337 --- [           main] o.s.i.monitor.IntegrationMBeanExporter   : Summary on shutdown: errorChannel
2018-06-20 15:08:57.958  INFO [test-service,,,] 29337 --- [           main] o.s.i.monitor.IntegrationMBeanExporter   : Summary on shutdown: hystrixStreamOutput
2018-06-20 15:08:57.958  INFO [test-service,,,] 29337 --- [           main] o.s.i.monitor.IntegrationMBeanExporter   : Summary on shutdown: _org.springframework.integration.errorLogger.handler
2018-06-20 15:08:57.958  INFO [test-service,,,] 29337 --- [           main] o.s.i.monitor.IntegrationMBeanExporter   : Summary on shutdown: org.springframework.integration.endpoint.MethodInvokingMessageSource@7779243b
2018-06-20 15:08:57.959  INFO [test-service,,,] 29337 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans on shutdown
2018-06-20 15:08:57.959  INFO [test-service,,,] 29337 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans
2018-06-20 15:08:57.980  INFO [test-service,,,] 29337 --- [           main] utoConfigurationReportLoggingInitializer : 

Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2018-06-20 15:08:57.980  INFO [test-service,,,] 29337 --- [           main] ationConfigEmbeddedWebApplicationContext : Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@4ad1ca85: startup date [Wed Jun 20 15:08:45 CST 2018]; parent: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@4f824872
2018-06-20 15:08:57.980  WARN [test-service,,,] 29337 --- [           main] ationConfigEmbeddedWebApplicationContext : Exception thrown from ApplicationListener handling ContextClosedEvent

java.lang.IllegalStateException: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@4f824872 has not been refreshed yet
	at org.springframework.context.support.AbstractApplicationContext.assertBeanFactoryActive(AbstractApplicationContext.java:1068) [spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1080) [spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.context.event.ApplicationListenerMethodAdapter.getTargetBean(ApplicationListenerMethodAdapter.java:280) ~[spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.context.event.ApplicationListenerMethodAdapter.doInvoke(ApplicationListenerMethodAdapter.java:250) ~[spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.context.event.ApplicationListenerMethodAdapter.processEvent(ApplicationListenerMethodAdapter.java:174) ~[spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.context.event.ApplicationListenerMethodAdapter.onApplicationEvent(ApplicationListenerMethodAdapter.java:137) ~[spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:167) [spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) [spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:383) [spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:389) [spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:337) [spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:994) [spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:961) [spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.boot.actuate.autoconfigure.EndpointWebMvcAutoConfiguration$CloseManagementContextListener.propagateCloseIfNecessary(EndpointWebMvcAutoConfiguration.java:309) [spring-boot-actuator-1.5.3.RELEASE.jar:1.5.3.RELEASE]
	at org.springframework.boot.actuate.autoconfigure.EndpointWebMvcAutoConfiguration$CloseManagementContextListener.onApplicationFailedEvent(EndpointWebMvcAutoConfiguration.java:304) [spring-boot-actuator-1.5.3.RELEASE.jar:1.5.3.RELEASE]
	at org.springframework.boot.actuate.autoconfigure.EndpointWebMvcAutoConfiguration$CloseManagementContextListener.onApplicationEvent(EndpointWebMvcAutoConfiguration.java:295) [spring-boot-actuator-1.5.3.RELEASE.jar:1.5.3.RELEASE]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:167) [spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) [spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:383) [spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:337) [spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.boot.context.event.EventPublishingRunListener.finished(EventPublishingRunListener.java:100) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
	at org.springframework.boot.SpringApplicationRunListeners.callFinishedListener(SpringApplicationRunListeners.java:79) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
	at org.springframework.boot.SpringApplicationRunListeners.finished(SpringApplicationRunListeners.java:72) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
	at org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:789) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:325) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
	at io.choerodon.test.TestServiceApplication.main(TestServiceApplication.java:20) [classes/:na]

2018-06-20 15:08:57.988 ERROR [test-service,,,] 29337 --- [           main] o.s.boot.SpringApplication               : Application startup failed

org.springframework.context.ApplicationContextException: Failed to start bean 'outputBindingLifecycle'; nested exception is org.springframework.cloud.stream.binder.BinderException: Exception thrown while building outbound endpoint
	at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:178) ~[spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:50) ~[spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:348) ~[spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:151) ~[spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:114) ~[spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:879) ~[spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:144) ~[spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:545) ~[spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
	at io.choerodon.test.TestServiceApplication.main(TestServiceApplication.java:20) [classes/:na]
Caused by: org.springframework.cloud.stream.binder.BinderException: Exception thrown while building outbound endpoint
	at org.springframework.cloud.stream.binder.AbstractMessageChannelBinder.doBindProducer(AbstractMessageChannelBinder.java:125) ~[spring-cloud-stream-1.2.2.RELEASE.jar:1.2.2.RELEASE]
	at org.springframework.cloud.stream.binder.AbstractMessageChannelBinder.doBindProducer(AbstractMessageChannelBinder.java:57) ~[spring-cloud-stream-1.2.2.RELEASE.jar:1.2.2.RELEASE]
	at org.springframework.cloud.stream.binder.AbstractBinder.bindProducer(AbstractBinder.java:152) ~[spring-cloud-stream-1.2.2.RELEASE.jar:1.2.2.RELEASE]
	at org.springframework.cloud.stream.binding.BindingService.bindProducer(BindingService.java:124) ~[spring-cloud-stream-1.2.2.RELEASE.jar:1.2.2.RELEASE]
	at org.springframework.cloud.stream.binding.BindableProxyFactory.bindOutputs(BindableProxyFactory.java:238) ~[spring-cloud-stream-1.2.2.RELEASE.jar:1.2.2.RELEASE]
	at org.springframework.cloud.stream.binding.OutputBindingLifecycle.start(OutputBindingLifecycle.java:57) ~[spring-cloud-stream-1.2.2.RELEASE.jar:1.2.2.RELEASE]
	at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:175) ~[spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	... 14 common frames omitted
Caused by: org.I0Itec.zkclient.exception.ZkTimeoutException: Unable to connect to zookeeper server within timeout: 10000
	at org.I0Itec.zkclient.ZkClient.connect(ZkClient.java:1232) ~[zkclient-0.9.jar:na]
	at org.I0Itec.zkclient.ZkClient.<init>(ZkClient.java:156) ~[zkclient-0.9.jar:na]
	at org.I0Itec.zkclient.ZkClient.<init>(ZkClient.java:130) ~[zkclient-0.9.jar:na]
	at kafka.utils.ZkUtils$.createZkClientAndConnection(ZkUtils.scala:76) ~[kafka_2.11-0.10.1.1.jar:na]
	at kafka.utils.ZkUtils$.apply(ZkUtils.scala:58) ~[kafka_2.11-0.10.1.1.jar:na]
	at kafka.utils.ZkUtils.apply(ZkUtils.scala) ~[kafka_2.11-0.10.1.1.jar:na]
	at org.springframework.cloud.stream.binder.kafka.provisioning.KafkaTopicProvisioner.createTopicAndPartitions(KafkaTopicProvisioner.java:171) ~[spring-cloud-stream-binder-kafka-core-1.2.1.RELEASE.jar:1.2.1.RELEASE]
	at org.springframework.cloud.stream.binder.kafka.provisioning.KafkaTopicProvisioner.createTopicsIfAutoCreateEnabledAndAdminUtilsPresent(KafkaTopicProvisioner.java:153) ~[spring-cloud-stream-binder-kafka-core-1.2.1.RELEASE.jar:1.2.1.RELEASE]
	at org.springframework.cloud.stream.binder.kafka.provisioning.KafkaTopicProvisioner.provisionProducerDestination(KafkaTopicProvisioner.java:108) ~[spring-cloud-stream-binder-kafka-core-1.2.1.RELEASE.jar:1.2.1.RELEASE]
	at org.springframework.cloud.stream.binder.kafka.provisioning.KafkaTopicProvisioner.provisionProducerDestination(KafkaTopicProvisioner.java:60) ~[spring-cloud-stream-binder-kafka-core-1.2.1.RELEASE.jar:1.2.1.RELEASE]
	at org.springframework.cloud.stream.binder.AbstractMessageChannelBinder.doBindProducer(AbstractMessageChannelBinder.java:110) ~[spring-cloud-stream-1.2.2.RELEASE.jar:1.2.2.RELEASE]
	... 20 common frames omitted

Disconnected from the target VM, address: '127.0.0.1:42855', transport: 'socket'

Process finished with exit code 1

你的配置看起来缺少了zk 的配置,可以在配置文件中添加zk的配置

demo程序并不需要连接kafka,麻烦提供下你看到的文档地址,我们这边修改一下

http://choerodon.io/zh/docs/development-guide/backend/demo/create_project/#添加默认配置文件

我的基本上采用的是这个http://choerodon.io/zh/docs/quick-start/microservice-backend/
你说的这个我之前也弄过,但是里面代码太杂了,有些都不通,所以就没采取了。

怎么修改哈,给贴出来哈:joy:

还有一个问题就是,访问这个swagger,认证的时候跳转报错


swagger点击接口旁边红点登录。docker-compose开发不方便,要是你要调试啥的最好起服务源码,我们本地也是启动的源码。文档正在修改。关于zookeeper,kafka,mysql如下:

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:
    - "./kafka/zk:/var/lib/zookeeper"
  kafka-0:
    container_name: kafka-0
    image: registry.saas.hand-china.com/tools/kafka:1.0.0
    hostname: 127.0.0.1
    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:
    - "./kafka/kafka:/opt/kafka/data"

  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:
    - ./mysql/mysql_data:/var/lib/mysql
    - ./mysql/mysql_db.cnf:/etc/mysql/conf.d/mysql_db.cnf
    expose:
    - "3306"

(⊙o⊙)…,我看你这个跟我的没多少差异呀,就改了下kafaka-0的hostname,还有通过接口的那个认证也是一样的,跳转一样的问题

oauth地址要通过manager的环境变量CHOERODON_SWAGGER_OAUTH_URL配置。你可以先试下我这个docker,因为我本地一直就是用这个,zookeeper没问题

我这不是本地起,而是把这些基础镜像在centos服务器上运行起来,然后我本地demo案例连接

哦,你还弄了个混合开发啊,拿你本地ping的通172.20.10.10?你centos防火墙允许9092了没?不是这些网络原因造成的吧?

应该不是网络原因吧,我ping过,可以通的哈。。。

不是防火墙9092端口没过吧。刚才本地试下了,我这是可以连上没问题的,我们现在zookeeper和kafka都是docker-compose运行的,docker-compose文件就是我上边贴的那个

@fuchen 如果你的docker地址不是localhost,则需要将kafka和zookeeper的hostname修改为对应的地址如:

version: "3"
services:
  zookeeper-0:
    container_name: zookeeper-0
    image: registry.cn-hangzhou.aliyuncs.com/choerodon-tools/zookeeper:3.4.10
    hostname: 192.168.99.100
    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
  kafka-0:
    container_name: kafka-0
    image: registry.cn-hangzhou.aliyuncs.com/choerodon-tools/kafka:1.0.0
    hostname: 192.168.99.100
    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=192.168.99.100:2181 \
           --override log.dirs=/opt/kafka/data/logs \
           --override broker.id=0 "

这个zk的由zookeeper-0改成服务器ip地址后,docker-compose运行时都起不来了 :joy:

是否端口被占用呢,检查下相关的端口。

virtualbox单启的centos服务器,防火墙我都直接给他禁掉了

有日志吗,查看下日志。

eureka-server      | 2018-06-21 10:15:28.337  INFO 1 --- [ XNIO-3 task-11] c.n.e.registry.AbstractInstanceRegistry  : Registered instance TEST-SERVICE/172.20.10.5:test-service:8080 with status UP (replication=false)
eureka-server      | 2018-06-21 10:15:28.564  INFO 1 --- [ XNIO-3 task-12] i.c.f.e.EurekaInstanceRegisteredListener : a instance up {"status":"UP","appName":"test-service","id":"172.20.10.5:test-service:8080","version":"null_version","uuid":""}
eureka-server      | 2018-06-21 10:15:28.564  INFO 1 --- [ XNIO-3 task-12] c.n.e.registry.AbstractInstanceRegistry  : Registered instance TEST-SERVICE/172.20.10.5:test-service:8080 with status UP (replication=true)
eureka-server      | 2018-06-21 10:15:29.243  INFO 1 --- [a-EvictionTimer] c.n.e.registry.AbstractInstanceRegistry  : Running the evict task with compensationTime 0ms
eureka-server      | 2018-06-21 10:15:33.253  INFO 1 --- [a-EvictionTimer] c.n.e.registry.AbstractInstanceRegistry  : Running the evict task with compensationTime 9ms
eureka-server      | 2018-06-21 10:15:37.254  INFO 1 --- [a-EvictionTimer] c.n.e.registry.AbstractInstanceRegistry  : Running the evict task with compensationTime 0ms
eureka-server      | 2018-06-21 10:15:39.449  INFO 1 --- [ XNIO-3 task-11] c.n.e.registry.AbstractInstanceRegistry  : Registered instance TEST-SERVICE/172.20.10.5:test-service:8080 with status DOWN (replication=false)
eureka-server      | 2018-06-21 10:15:39.457  INFO 1 --- [ XNIO-3 task-12] c.n.e.registry.AbstractInstanceRegistry  : Cancelled instance TEST-SERVICE/172.20.10.5:test-service:8080 (replication=false)
eureka-server      | 2018-06-21 10:15:39.844  INFO 1 --- [ XNIO-3 task-10] i.c.f.e.EurekaInstanceRegisteredListener : a instance up {"status":"DOWN","appName":"test-service","id":"172.20.10.5:test-service:8080","version":"null_version","uuid":""}
eureka-server      | 2018-06-21 10:15:39.844  INFO 1 --- [ XNIO-3 task-10] c.n.e.registry.AbstractInstanceRegistry  : Registered instance TEST-SERVICE/172.20.10.5:test-service:8080 with status DOWN (replication=true)
eureka-server      | 2018-06-21 10:15:39.844  INFO 1 --- [ XNIO-3 task-10] c.n.e.registry.AbstractInstanceRegistry  : Cancelled instance TEST-SERVICE/172.20.10.5:test-service:8080 (replication=true)
eureka-server      | 2018-06-21 10:15:41.255  INFO 1 --- [a-EvictionTimer] c.n.e.registry.AbstractInstanceRegistry  : Running the evict task with compensationTime 0ms

demo案例连接时,我查看了下eureka-server的日志,如上:
demo案例运行的控制台日志如下:

2018-06-21 10:15:38.116  INFO [test-service,,,] 29147 --- [localhost:2181)] org.apache.zookeeper.ClientCnxn          : Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
2018-06-21 10:15:38.117  WARN [test-service,,,] 29147 --- [localhost:2181)] org.apache.zookeeper.ClientCnxn          : Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect

java.net.ConnectException: 拒绝连接
	at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) ~[na:1.8.0_151]
	at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717) ~[na:1.8.0_151]
	at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:361) ~[zookeeper-3.4.8.jar:3.4.8--1]
	at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1141) ~[zookeeper-3.4.8.jar:3.4.8--1]

2018-06-21 10:15:39.218  INFO [test-service,,,] 29147 --- [localhost:2181)] org.apache.zookeeper.ClientCnxn          : Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
2018-06-21 10:15:39.220  WARN [test-service,,,] 29147 --- [localhost:2181)] org.apache.zookeeper.ClientCnxn          : Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect

java.net.ConnectException: 拒绝连接
	at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) ~[na:1.8.0_151]
	at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717) ~[na:1.8.0_151]
	at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:361) ~[zookeeper-3.4.8.jar:3.4.8--1]
	at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1141) ~[zookeeper-3.4.8.jar:3.4.8--1]

2018-06-21 10:15:39.326  INFO [test-service,,,] 29147 --- [           main] org.apache.zookeeper.ZooKeeper           : Session: 0x0 closed
2018-06-21 10:15:39.326  INFO [test-service,,,] 29147 --- [ain-EventThread] org.apache.zookeeper.ClientCnxn          : EventThread shut down for session: 0x0
2018-06-21 10:15:39.327  WARN [test-service,,,] 29147 --- [           main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Failed to start bean 'outputBindingLifecycle'; nested exception is org.springframework.cloud.stream.binder.BinderException: Exception thrown while building outbound endpoint
2018-06-21 10:15:39.333  INFO [test-service,,,] 29147 --- [           main] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@5b5d2971: startup date [Thu Jun 21 10:15:28 CST 2018]; parent: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@724f138e
2018-06-21 10:15:39.336  INFO [test-service,,,] 29147 --- [           main] o.s.c.n.e.s.EurekaServiceRegistry        : Unregistering application test-service with eureka with status DOWN
2018-06-21 10:15:39.337  WARN [test-service,,,] 29147 --- [           main] com.netflix.discovery.DiscoveryClient    : Saw local status change event StatusChangeEvent [timestamp=1529547339337, current=DOWN, previous=UP]
2018-06-21 10:15:39.337  INFO [test-service,,,] 29147 --- [           main] com.netflix.discovery.DiscoveryClient    : Shutting down DiscoveryClient ...
2018-06-21 10:15:39.337  INFO [test-service,,,] 29147 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_TEST-SERVICE/172.20.10.5:test-service:8080: registering service...
2018-06-21 10:15:39.339  INFO [test-service,,,] 29147 --- [           main] com.netflix.discovery.DiscoveryClient    : Unregistering ...
2018-06-21 10:15:39.348  INFO [test-service,,,] 29147 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_TEST-SERVICE/172.20.10.5:test-service:8080 - registration status: 204
2018-06-21 10:15:39.356  INFO [test-service,,,] 29147 --- [           main] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_TEST-SERVICE/172.20.10.5:test-service:8080 - deregister  status: 200
2018-06-21 10:15:39.360  INFO [test-service,,,] 29147 --- [           main] com.netflix.discovery.DiscoveryClient    : Completed shut down of DiscoveryClient
2018-06-21 10:15:39.361  INFO [test-service,,,] 29147 --- [           main] o.s.s.c.ThreadPoolTaskScheduler          : Shutting down ExecutorService 'taskScheduler'
2018-06-21 10:15:39.362  INFO [test-service,,,] 29147 --- [           main] o.s.i.monitor.IntegrationMBeanExporter   : Unregistering JMX-exposed beans on shutdown
2018-06-21 10:15:39.362  INFO [test-service,,,] 29147 --- [           main] o.s.i.monitor.IntegrationMBeanExporter   : Unregistering JMX-exposed beans
2018-06-21 10:15:39.362  INFO [test-service,,,] 29147 --- [           main] o.s.i.monitor.IntegrationMBeanExporter   : Summary on shutdown: sleuth
2018-06-21 10:15:39.362  INFO [test-service,,,] 29147 --- [           main] o.s.i.monitor.IntegrationMBeanExporter   : Summary on shutdown: nullChannel
2018-06-21 10:15:39.362  INFO [test-service,,,] 29147 --- [           main] o.s.i.monitor.IntegrationMBeanExporter   : Summary on shutdown: springCloudBusOutput
2018-06-21 10:15:39.362  INFO [test-service,,,] 29147 --- [           main] o.s.i.monitor.IntegrationMBeanExporter   : Summary on shutdown: errorChannel
2018-06-21 10:15:39.362  INFO [test-service,,,] 29147 --- [           main] o.s.i.monitor.IntegrationMBeanExporter   : Summary on shutdown: hystrixStreamOutput
2018-06-21 10:15:39.362  INFO [test-service,,,] 29147 --- [           main] o.s.i.monitor.IntegrationMBeanExporter   : Summary on shutdown: springCloudBusInput
2018-06-21 10:15:39.362  INFO [test-service,,,] 29147 --- [           main] o.s.i.monitor.IntegrationMBeanExporter   : Summary on shutdown: _org.springframework.integration.errorLogger.handler
2018-06-21 10:15:39.362  INFO [test-service,,,] 29147 --- [           main] o.s.i.monitor.IntegrationMBeanExporter   : Summary on shutdown: org.springframework.integration.endpoint.MethodInvokingMessageSource@61ed43ae
2018-06-21 10:15:39.362  INFO [test-service,,,] 29147 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans on shutdown
2018-06-21 10:15:39.362  INFO [test-service,,,] 29147 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans
2018-06-21 10:15:39.380  INFO [test-service,,,] 29147 --- [           main] utoConfigurationReportLoggingInitializer : 

Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2018-06-21 10:15:39.380  INFO [test-service,,,] 29147 --- [           main] ationConfigEmbeddedWebApplicationContext : Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@3650cc1a: startup date [Thu Jun 21 10:15:27 CST 2018]; parent: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@724f138e
2018-06-21 10:15:39.381  WARN [test-service,,,] 29147 --- [           main] ationConfigEmbeddedWebApplicationContext : Exception thrown from ApplicationListener handling ContextClosedEvent

java.lang.IllegalStateException: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@724f138e has not been refreshed yet
	at org.springframework.context.support.AbstractApplicationContext.assertBeanFactoryActive(AbstractApplicationContext.java:1068) [spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1080) [spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.context.event.ApplicationListenerMethodAdapter.getTargetBean(ApplicationListenerMethodAdapter.java:280) ~[spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.context.event.ApplicationListenerMethodAdapter.doInvoke(ApplicationListenerMethodAdapter.java:250) ~[spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.context.event.ApplicationListenerMethodAdapter.processEvent(ApplicationListenerMethodAdapter.java:174) ~[spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.context.event.ApplicationListenerMethodAdapter.onApplicationEvent(ApplicationListenerMethodAdapter.java:137) ~[spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:167) [spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) [spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:383) [spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:389) [spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:337) [spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:994) [spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:961) [spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.boot.actuate.autoconfigure.EndpointWebMvcAutoConfiguration$CloseManagementContextListener.propagateCloseIfNecessary(EndpointWebMvcAutoConfiguration.java:309) [spring-boot-actuator-1.5.3.RELEASE.jar:1.5.3.RELEASE]
	at org.springframework.boot.actuate.autoconfigure.EndpointWebMvcAutoConfiguration$CloseManagementContextListener.onApplicationFailedEvent(EndpointWebMvcAutoConfiguration.java:304) [spring-boot-actuator-1.5.3.RELEASE.jar:1.5.3.RELEASE]
	at org.springframework.boot.actuate.autoconfigure.EndpointWebMvcAutoConfiguration$CloseManagementContextListener.onApplicationEvent(EndpointWebMvcAutoConfiguration.java:295) [spring-boot-actuator-1.5.3.RELEASE.jar:1.5.3.RELEASE]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:167) [spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) [spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:383) [spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:337) [spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.boot.context.event.EventPublishingRunListener.finished(EventPublishingRunListener.java:100) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
	at org.springframework.boot.SpringApplicationRunListeners.callFinishedListener(SpringApplicationRunListeners.java:79) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
	at org.springframework.boot.SpringApplicationRunListeners.finished(SpringApplicationRunListeners.java:72) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
	at org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:789) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:325) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
	at io.choerodon.test.TestServiceApplication.main(TestServiceApplication.java:20) [classes/:na]

2018-06-21 10:15:39.390 ERROR [test-service,,,] 29147 --- [           main] o.s.boot.SpringApplication               : Application startup failed

org.springframework.context.ApplicationContextException: Failed to start bean 'outputBindingLifecycle'; nested exception is org.springframework.cloud.stream.binder.BinderException: Exception thrown while building outbound endpoint
	at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:178) ~[spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:50) ~[spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:348) ~[spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:151) ~[spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:114) ~[spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:879) ~[spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:144) ~[spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:545) ~[spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
	at io.choerodon.test.TestServiceApplication.main(TestServiceApplication.java:20) [classes/:na]
Caused by: org.springframework.cloud.stream.binder.BinderException: Exception thrown while building outbound endpoint
	at org.springframework.cloud.stream.binder.AbstractMessageChannelBinder.doBindProducer(AbstractMessageChannelBinder.java:125) ~[spring-cloud-stream-1.2.2.RELEASE.jar:1.2.2.RELEASE]
	at org.springframework.cloud.stream.binder.AbstractMessageChannelBinder.doBindProducer(AbstractMessageChannelBinder.java:57) ~[spring-cloud-stream-1.2.2.RELEASE.jar:1.2.2.RELEASE]
	at org.springframework.cloud.stream.binder.AbstractBinder.bindProducer(AbstractBinder.java:152) ~[spring-cloud-stream-1.2.2.RELEASE.jar:1.2.2.RELEASE]
	at org.springframework.cloud.stream.binding.BindingService.bindProducer(BindingService.java:124) ~[spring-cloud-stream-1.2.2.RELEASE.jar:1.2.2.RELEASE]
	at org.springframework.cloud.stream.binding.BindableProxyFactory.bindOutputs(BindableProxyFactory.java:238) ~[spring-cloud-stream-1.2.2.RELEASE.jar:1.2.2.RELEASE]
	at org.springframework.cloud.stream.binding.OutputBindingLifecycle.start(OutputBindingLifecycle.java:57) ~[spring-cloud-stream-1.2.2.RELEASE.jar:1.2.2.RELEASE]
	at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:175) ~[spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	... 14 common frames omitted
Caused by: org.I0Itec.zkclient.exception.ZkTimeoutException: Unable to connect to zookeeper server within timeout: 10000
	at org.I0Itec.zkclient.ZkClient.connect(ZkClient.java:1232) ~[zkclient-0.9.jar:na]
	at org.I0Itec.zkclient.ZkClient.<init>(ZkClient.java:156) ~[zkclient-0.9.jar:na]
	at org.I0Itec.zkclient.ZkClient.<init>(ZkClient.java:130) ~[zkclient-0.9.jar:na]
	at kafka.utils.ZkUtils$.createZkClientAndConnection(ZkUtils.scala:76) ~[kafka_2.11-0.10.1.1.jar:na]
	at kafka.utils.ZkUtils$.apply(ZkUtils.scala:58) ~[kafka_2.11-0.10.1.1.jar:na]
	at kafka.utils.ZkUtils.apply(ZkUtils.scala) ~[kafka_2.11-0.10.1.1.jar:na]
	at org.springframework.cloud.stream.binder.kafka.provisioning.KafkaTopicProvisioner.createTopicAndPartitions(KafkaTopicProvisioner.java:171) ~[spring-cloud-stream-binder-kafka-core-1.2.1.RELEASE.jar:1.2.1.RELEASE]
	at org.springframework.cloud.stream.binder.kafka.provisioning.KafkaTopicProvisioner.createTopicsIfAutoCreateEnabledAndAdminUtilsPresent(KafkaTopicProvisioner.java:153) ~[spring-cloud-stream-binder-kafka-core-1.2.1.RELEASE.jar:1.2.1.RELEASE]
	at org.springframework.cloud.stream.binder.kafka.provisioning.KafkaTopicProvisioner.provisionProducerDestination(KafkaTopicProvisioner.java:108) ~[spring-cloud-stream-binder-kafka-core-1.2.1.RELEASE.jar:1.2.1.RELEASE]
	at org.springframework.cloud.stream.binder.kafka.provisioning.KafkaTopicProvisioner.provisionProducerDestination(KafkaTopicProvisioner.java:60) ~[spring-cloud-stream-binder-kafka-core-1.2.1.RELEASE.jar:1.2.1.RELEASE]
	at org.springframework.cloud.stream.binder.AbstractMessageChannelBinder.doBindProducer(AbstractMessageChannelBinder.java:110) ~[spring-cloud-stream-1.2.2.RELEASE.jar:1.2.2.RELEASE]
	... 20 common frames omitted


Process finished with exit code 1

你说的这个swagger这个认证,需要怎么配置这个环境变量哈,具体给一下哈

@fuchen 因为你是在服务器上启动的环境,kafka如果绑定到localhost则本机无法访问,改为服务器的ip之后则需要同步修改服务器上的所有服务kafka地址,这样比较麻烦。
另外有一种方案:使用原来的docker-compose文件,修改本机的 hosts文件添加如下内容 192.168.99.100换成你的服务器地址,本地demo使用 kafka-0,zookeeper-0配置连接。

192.168.99.100  zookeeper-0
192.168.99.100  kafka-0