- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当我通过Spring-Boot可运行的jar文件分别启动Eureka和Zuul时,一切似乎都正常运行。但是,当我尝试在Docker容器中运行每个容器并将它们与Docker-Compose连接时,Zuul网关无法找到Eureka服务器。
docker-compose.yml:
version: '3.6'
services:
eureka-serviceregistry:
container_name: serviceregistry
build: ./ServiceRegistry
ports:
- "8761:8761"
hostname: serviceregistry
environment:
eureka.client.serviceUrl.defaultZone: http://serviceregistry:8761/eureka/
zuul-edgeservice:
container_name: gateway
build: ./ServiceGateway
ports:
- "8080:8080"
hostname: gateway
environment:
eureka.client.serviceUrl.defaultZone: http://serviceregistry:8761/eureka/
FROM openjdk:8-jdk-alpine
# Add Spring Boot app.jar to Container
COPY /build/libs/ServiceRegistry-0.0.1-SNAPSHOT.jar /usr/local/ServiceRegistry.jar
EXPOSE 8761
# Fire up our Spring Boot app by default
ENTRYPOINT [ "sh", "-c", "java -Djava.security.egd=file:/dev/./urandom -jar /usr/local/ServiceRegistry.jar" ]
server.port=8761
spring.application.name=EurekaServiceRegistry
eureka.client.register-with-eureka=true
eureka.client.fetch-registry=false
eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka
eureka.instance.hostname=EurekaServiceRegistry
logging.level.com.netflix.eureka=INFO
logging.level.com.netflix.discovery=INFO
@EnableEurekaServer
@SpringBootApplication
public class QQServiceRegistry {
public static void main(String[] args) {
SpringApplication.run(QQServiceRegistry.class, args);
}
}
FROM openjdk:8-jdk-alpine
# Add Spring Boot app.jar to Container
COPY /build/libs/ServiceGateway-0.0.1-SNAPSHOT.jar /usr/local/ServiceGateway.jar
EXPOSE 8080
# Fire up our Spring Boot app by default
ENTRYPOINT [ "sh", "-c", "java -Djava.security.egd=file:/dev/./urandom -jar /usr/local/ServiceGateway.jar" ]
zuul.routes.auth.path=/enterprise_service/**
zuul.routes.auth.service-id=ENTERPRISE_SERVICE
eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka
@EnableZuulProxy
@SpringBootApplication
public class ServiceGateway {
public static void main(String[] args) {
SpringApplication.run(ServiceGateway.class, args);
}
}
buildscript {
ext {
springBootVersion = '2.0.1.RELEASE'
}
repositories {
jcenter()
}
dependencies {
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4+"
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
subprojects {
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'com.jfrog.artifactory'
apply plugin: 'maven-publish'
sourceCompatibility = 1.8
targetCompatibility = 1.8
artifactory {
contextUrl = "${artifactory_contextUrl}"
publish {
repository {
repoKey = 'gradle-dev-local'
username = "${artifactory_user}"
password = "${artifactory_password}"
maven = true
}
defaults {
publications ('mavenJava')
}
}
resolve {
repository {
repoKey = 'gradle-dev'
username = "${artifactory_user}"
password = "${artifactory_password}"
maven = true
}
}
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
}
artifactoryPublish {
dependsOn assemble
}
dependencyManagement {
imports {
mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Finchley.M8'
}
}
repositories {
maven {
url 'https://repo.spring.io/libs-milestone'
}
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-actuator')
compile('org.springframework.boot:spring-boot-starter-web')
testCompile('org.springframework.boot:spring-boot-starter-test')
}
bootJar {
launchScript()
}
}
group = 'my.company.service.infrastructure.registry'
version = '0.0.1-SNAPSHOT'
dependencies {
compile('org.springframework.cloud:spring-cloud-starter-netflix-eureka-server')
}
group = 'my.company.service.infrastructure.gateway'
version = '0.0.1-SNAPSHOT'
dependencies {
compile('org.springframework.cloud:spring-cloud-starter-netflix-zuul')
compile('org.springframework.cloud:spring-cloud-starter-netflix-eureka-client')
}
2018-04-11 15:38:20.136 INFO 6 --- [nfoReplicator-0] >com.netflix.discovery.DiscoveryClient : DiscoveryClient_UNKNOWN/gateway: >registering service... 2018-04-11 15:38:20.139 ERROR 6 --- [nfoReplicator-0] >c.n.d.s.t.d.RedirectingEurekaHttpClient : Request execution error
com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: >Connection refused (Connection refused) at >com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(ApacheHttpClient4>Handler.java:187) ~[jersey-apache-client4-1.19.1.jar!/:1.19.1] at >com.sun.jersey.api.client.filter.GZIPContentEncodingFilter.handle(GZIPContentEn>codingFilter.java:123) ~[jersey-client-1.19.1.jar!/:1.19.1] at >com.netflix.discovery.EurekaIdentityHeaderFilter.handle(EurekaIdentityHeaderFil>ter.java:27) ~[eureka-client-1.8.6.jar!/:1.8.6] at com.sun.jersey.api.client.Client.handle(Client.java:652) ~[jersey-client->1.19.1.jar!/:1.19.1] at com.sun.jersey.api.client.WebResource.handle(WebResource.java:682) ~>>[jersey-client-1.19.1.jar!/:1.19.1] at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74) ~>[jersey-client-1.19.1.jar!/:1.19.1] at com.sun.jersey.api.client.WebResource$Builder.post(WebResource.java:570) >~[jersey-client-1.19.1.jar!/:1.19.1] at >com.netflix.discovery.shared.transport.jersey.AbstractJerseyEurekaHttpClient.re>gister(AbstractJerseyEurekaHttpClient.java:56) ~[eureka-client->1.8.6.jar!/:1.8.6] at >com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$1.ex>ecute(EurekaHttpClientDecorator.java:59) [eureka-client-1.8.6.jar!/:1.8.6] at >com.netflix.discovery.shared.transport.decorator.MetricsCollectingEurekaHttpCli>ent.execute(MetricsCollectingEurekaHttpClient.java:73) ~[eureka-client->1.8.6.jar!/:1.8.6] at >com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.regi>ster(EurekaHttpClientDecorator.java:56) [eureka-client-1.8.6.jar!/:1.8.6] at >com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$1.ex>ecute(EurekaHttpClientDecorator.java:59) [eureka-client-1.8.6.jar!/:1.8.6] at >com.netflix.discovery.shared.transport.decorator.RedirectingEurekaHttpClient.ex>ecuteOnNewServer(RedirectingEurekaHttpClient.java:118) ~[eureka-client->1.8.6.jar!/:1.8.6] at >com.netflix.discovery.shared.transport.decorator.RedirectingEurekaHttpClient.ex>ecute(RedirectingEurekaHttpClient.java:79) ~[eureka-client-1.8.6.jar!/:1.8.6] at >com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.regi>ster(EurekaHttpClientDecorator.java:56) [eureka-client-1.8.6.jar!/:1.8.6] at >com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$1.ex>ecute(EurekaHttpClientDecorator.java:59) [eureka-client-1.8.6.jar!/:1.8.6] at >com.netflix.discovery.shared.transport.decorator.RetryableEurekaHttpClient.exec>ute(RetryableEurekaHttpClient.java:119) [eureka-client-1.8.6.jar!/:1.8.6] at >com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.regi>ster(EurekaHttpClientDecorator.java:56) [eureka-client-1.8.6.jar!/:1.8.6] at >com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$1.ex>ecute(EurekaHttpClientDecorator.java:59) [eureka-client-1.8.6.jar!/:1.8.6] at >com.netflix.discovery.shared.transport.decorator.SessionedEurekaHttpClient.exec>ute(SessionedEurekaHttpClient.java:77) [eureka-client-1.8.6.jar!/:1.8.6] at >com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.regi>ster(EurekaHttpClientDecorator.java:56) [eureka-client-1.8.6.jar!/:1.8.6] at com.netflix.discovery.DiscoveryClient.register(DiscoveryClient.java:829) >[eureka-client-1.8.6.jar!/:1.8.6] at >com.netflix.discovery.InstanceInfoReplicator.run(InstanceInfoReplicator.java:10>4) [eureka-client-1.8.6.jar!/:1.8.6] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) >[na:1.8.0_151] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_151] at >java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201>(ScheduledThreadPoolExecutor.java:180) [na:1.8.0_151] at >java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Schedu>ledThreadPoolExecutor.java:293) [na:1.8.0_151] at >java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) >[na:1.8.0_151] at >java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) >[na:1.8.0_151] at java.lang.Thread.run(Thread.java:748) [na:1.8.0_151] Caused by: java.net.ConnectException: Connection refused (Connection refused) at java.net.PlainSocketImpl.socketConnect(Native Method) ~[na:1.8.0_151] at >java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) ~>[na:1.8.0_151] at >java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:>206) ~[na:1.8.0_151] at >java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~>[na:1.8.0_151] at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~>[na:1.8.0_151] at java.net.Socket.connect(Socket.java:589) ~[na:1.8.0_151] at >org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory>.java:121) ~[httpclient-4.5.5.jar!/:4.5.5] at >org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(Defaul>tClientConnectionOperator.java:180) ~[httpclient-4.5.5.jar!/:4.5.5] at >org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:144) ~>[httpclient-4.5.5.jar!/:4.5.5] at >org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdap>ter.java:134) ~[httpclient-4.5.5.jar!/:4.5.5] at >org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDir>ector.java:610) ~[httpclient-4.5.5.jar!/:4.5.5] at >org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirect>or.java:445) ~[httpclient-4.5.5.jar!/:4.5.5] at >org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.jav>a:835) ~[httpclient-4.5.5.jar!/:4.5.5] at >org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.jav>a:118) ~[httpclient-4.5.5.jar!/:4.5.5] at >org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.jav>a:56) ~[httpclient-4.5.5.jar!/:4.5.5] at >com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(ApacheHttpClient4>Handler.java:173) ~[jersey-apache-client4-1.19.1.jar!/:1.19.1] ... 29 common frames omitted
2018-04-11 15:38:20.140 WARN 6 --- [nfoReplicator-0] >c.n.d.s.t.d.RetryableEurekaHttpClient : Request execution failed with >message: java.net.ConnectException: Connection refused (Connection refused) 2018-04-11 15:38:20.140 WARN 6 --- [nfoReplicator-0] >com.netflix.discovery.DiscoveryClient : DiscoveryClient_UNKNOWN/gateway - >registration failed Cannot execute request on any known server
com.netflix.discovery.shared.transport.TransportException: Cannot execute >request on any known server at >com.netflix.discovery.shared.transport.decorator.RetryableEurekaHttpClient.exec>ute(RetryableEurekaHttpClient.java:111) ~[eureka-client-1.8.6.jar!/:1.8.6] at >com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.regi>ster(EurekaHttpClientDecorator.java:56) ~[eureka-client-1.8.6.jar!/:1.8.6] at >com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$1.ex>ecute(EurekaHttpClientDecorator.java:59) ~[eureka-client-1.8.6.jar!/:1.8.6] at >com.netflix.discovery.shared.transport.decorator.SessionedEurekaHttpClient.exec>ute(SessionedEurekaHttpClient.java:77) ~[eureka-client-1.8.6.jar!/:1.8.6] at >com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.regi>ster(EurekaHttpClientDecorator.java:56) ~[eureka-client-1.8.6.jar!/:1.8.6] at com.netflix.discovery.DiscoveryClient.register(DiscoveryClient.java:829) >~[eureka-client-1.8.6.jar!/:1.8.6] at >com.netflix.discovery.InstanceInfoReplicator.run(InstanceInfoReplicator.java:10>4) [eureka-client-1.8.6.jar!/:1.8.6] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) >[na:1.8.0_151] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_151] at >java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201>(ScheduledThreadPoolExecutor.java:180) [na:1.8.0_151] at >java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Schedu>ledThreadPoolExecutor.java:293) [na:1.8.0_151] at >java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) >[na:1.8.0_151] at >java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) >[na:1.8.0_151] at java.lang.Thread.run(Thread.java:748) [na:1.8.0_151]
2018-04-11 15:38:20.141 WARN 6 --- [nfoReplicator-0] >c.n.discovery.InstanceInfoReplicator : There was a problem with the >instance info replicator
com.netflix.discovery.shared.transport.TransportException: Cannot execute >request on any known server at >com.netflix.discovery.shared.transport.decorator.RetryableEurekaHttpClient.exec>ute(RetryableEurekaHttpClient.java:111) ~[eureka-client-1.8.6.jar!/:1.8.6] at >com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.regi>ster(EurekaHttpClientDecorator.java:56) ~[eureka-client-1.8.6.jar!/:1.8.6] at >com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$1.ex>ecute(EurekaHttpClientDecorator.java:59) ~[eureka-client-1.8.6.jar!/:1.8.6] at >com.netflix.discovery.shared.transport.decorator.SessionedEurekaHttpClient.exec>ute(SessionedEurekaHttpClient.java:77) ~[eureka-client-1.8.6.jar!/:1.8.6] at >com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.regi>ster(EurekaHttpClientDecorator.java:56) ~[eureka-client-1.8.6.jar!/:1.8.6] at com.netflix.discovery.DiscoveryClient.register(DiscoveryClient.java:829) >~[eureka-client-1.8.6.jar!/:1.8.6] at >com.netflix.discovery.InstanceInfoReplicator.run(InstanceInfoReplicator.java:10>4) ~[eureka-client-1.8.6.jar!/:1.8.6] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) >[na:1.8.0_151] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_151] at >java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201>(ScheduledThreadPoolExecutor.java:180) [na:1.8.0_151] at >java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Schedu>ledThreadPoolExecutor.java:293) [na:1.8.0_151] at >java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) >[na:1.8.0_151] at >java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) >[na:1.8.0_151] at java.lang.Thread.run(Thread.java:748) [na:1.8.0_151]
2018-04-11 15:38:50.043 ERROR 6 --- [tbeatExecutor-0] >c.n.d.s.t.d.RedirectingEurekaHttpClient : Request execution error
最佳答案
问题是YAML语法错误。
以下docker-compose.yml可以工作。注意环境部分。
version: '3.6'
services:
eureka-serviceregistry:
container_name: serviceregistry
build: ./ServiceRegistry
ports:
- 8761:8761
hostname: serviceregistry
environment:
- EUREKA_CLIENT_SERVICEURL_DEFAULTZONE=http://serviceregistry:8761/eureka
zuul-edgeservice:
container_name: gateway
build: ./ServiceGateway
ports:
- 8080:8080
hostname: gateway
environment:
- EUREKA_CLIENT_SERVICEURL_DEFAULTZONE=http://serviceregistry:8761/eureka
关于docker - Zuul网关无法在Docker-Compose下连接到Eureka服务注册表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49779491/
我使用以下命令使用 Composer 删除了一个包。 composer remove sjparkinson/static-review 以上命令从 composer.json 中删除条目文件但 co
我刚刚开始使用 Composer 功能,你告诉它查看本地目录的依赖关系,这样你就可以开发一个库和一些并行使用该库的东西,而不必一直推送到 git 来更新,这是惊人的。例如 "repositories"
composer 和有什么区别和 composer.phar ? 例子: composer install composer.phar install 我一直看到使用 composer.phar 编写
阅读docker-compose -h或this official manual的帮助将为我们提供--project-directory PATH选项 docker-compose [-f ...]
我已经使用他们的安装指南在我的 Linux/Apache 服务器上的根目录(这是默认选择)中成功安装了 Composer。到目前为止,一切都非常简单,除了我必须进行的一个 php.ini 调整( de
在我的 composer.json配置文件,我有: "require": { "zendframework/zend-log" : "~2.3", }, "require-dev": {
从 Composer 安装此软件包后,我想复制位于软件包内的一些文件。 实际上,我希望在从 Composer 安装或更新软件包后,将下载的软件包中可能存在的某个文件复制到另一个目录。我用 script
我对码头公司还是个新手。我使用的是最新版本的Python、Django和Docker。我已经在这个项目上工作了两周了,我已经创建了docker-compose.yml文件,并且已经构建了我的docke
我正在尝试使用 composer 安装一个 github 项目并得到以下错误 Composer [UnexpectedValueException]您的 github.com 的 Github oau
我开发 Symfony 包的工作流程如下: 安装 Symfony 为新包创建一个 git repo,在其中放置一个 composer.json 文件 需要顶级 composer.json 中的新包,使
我正在尝试使用 composer 安装 github 项目并收到以下错误 Composer [UnexpectedValueException] 您用于 github.com 的 Github oau
我们在项目中使用了 composer。当我开发和/或向项目提交任何内容时,我通常应该使用 composer install;更新依赖项只是偶尔进行。 我们还使用 https://github.com/
我在 youtube 上学会了这个抽屉 https://www.youtube.com/watch?v=JLICaBEiJS0&list=PLQkwcJG4YTCSpJ2NLhDTHhi6XBNfk9
我知道在 onClick 中调用可组合函数是不可能的。 @Composable 调用只能在 @Composable 函数的上下文中发生 撰写版本 - alpha06 但我坚持以下要求。 要求是, 在
这是我的 docker-compose.yml 文件: version: '3.1' services: a: image: tutum/hello-world b: imag
创建Asset实例时是否有auto_increment字段类型可用。例如, Assets ID 应该是自动生成的字段,应该在运行时创建,而不是在应用程序级别提及该值。我可以通过创建一个交易处理器函数来
在 Composer 项目中,我必须添加一个库,它没有 composer.json 并且不使用命名空间。因此,我调整了项目的 composer.json 以添加库: { [...] "
当 vendor 目录中已经有一些组件被下载时.. 在上面运行 install 以及运行 update 时有什么影响? 最佳答案 所以我有同样的问题,这是我发现的: composer install
尝试运行 composer install 时出现此错误。我已经运行了 composer update,我正在尝试使用这个最新的锁定文件进行安装。没有任何帮助。 Loading composer re
当我尝试做: $ sudo php composer.phar update 我收到此警告: Warning: This development build of composer is over 3
我是一名优秀的程序员,十分优秀!