Spring cloud 在Consor first安装程序中找不到配置服务器
我使用的是领事优先设置。为此,我正在使用一个领事docker映像,端口8500映射到8500,这样我就可以在本地设置中成功地使用它 我对配置服务器有以下配置- pom.xmlSpring cloud 在Consor first安装程序中找不到配置服务器,spring-cloud,service-discovery,spring-cloud-config,spring-cloud-consul,Spring Cloud,Service Discovery,Spring Cloud Config,Spring Cloud Consul,我使用的是领事优先设置。为此,我正在使用一个领事docker映像,端口8500映射到8500,这样我就可以在本地设置中成功地使用它 我对配置服务器有以下配置- pom.xml <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-config-server&
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-discovery</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Dalston.RC1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
server:
port: 8888
spring:
cloud:
config:
server:
git:
uri: https://github.com/xxxxxx/spring-config-repo.git
consul:
host: consul
port: 8500
enabled: true
discovery:
enabled: true
register: true
service-name: configservice
spring:
application:
name: config-server
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-all</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Dalston.RC1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
spring:
application:
name: myservice
cloud:
config:
fail-fast: true
retry:
max-attempts: 20
initial-interval: 3000
enabled: true
discovery:
enabled: true
service-id: configserver
consul:
host: localhost
port: 8500
discovery:
enabled: true
register: true
service-name: myservice
server:
port: 8081
bootstrap.yml
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-discovery</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Dalston.RC1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
server:
port: 8888
spring:
cloud:
config:
server:
git:
uri: https://github.com/xxxxxx/spring-config-repo.git
consul:
host: consul
port: 8500
enabled: true
discovery:
enabled: true
register: true
service-name: configservice
spring:
application:
name: config-server
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-all</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Dalston.RC1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
spring:
application:
name: myservice
cloud:
config:
fail-fast: true
retry:
max-attempts: 20
initial-interval: 3000
enabled: true
discovery:
enabled: true
service-id: configserver
consul:
host: localhost
port: 8500
discovery:
enabled: true
register: true
service-name: myservice
server:
port: 8081
ConfigServerApplication.java
@EnableConfigServer
@EnableDiscoveryClient
@SpringBootApplication
public class ConfigServiceApplication {
public static void main(String[] args) {
SpringApplication.run(ConfigServiceApplication.class, args);
}
}
@EnableDiscoveryClient
@SpringBootApplication
public class MyServiceApplication {
public static void main(String[] args) {
SpringApplication.run(ApplePaymentServiceApplication.class, args);
}
}
当我运行这个jar时,它是成功的。我可以在Consor ui中看到配置服务器。
以下是从concur看到的配置服务器的详细信息-
Request - http://localhost:8500/v1/catalog/services
Response -
{
"configservice": [],
"consul": []
}
Request - http://localhost:8500/v1/catalog/service/configservice
Response -
[
{
"ID": "f6ac953c-07b9-4097-974e-3ea9cd39bec2",
"Node": "a0954c644062",
"Address": "127.0.0.1",
"TaggedAddresses": {
"lan": "127.0.0.1",
"wan": "127.0.0.1"
},
"NodeMeta": {},
"ServiceID": "config-server-8888",
"ServiceName": "configservice",
"ServiceTags": [],
"ServiceAddress": "10.0.0.158",
"ServicePort": 8888,
"ServiceEnableTagOverride": false,
"CreateIndex": 15,
"ModifyIndex": 15
}
]
我还可以使用此uri访问配置服务器-
http://localhost:8888/configclient/default
我有一个客户端应用程序,它使用配置服务器的属性。我的理解是,当我运行这个jar时,它将联系concur,从那里获取配置服务器信息,并通过从给定的git uri获取属性来填充属性
以下是有关该客户机的详细信息-
pom.xml
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-discovery</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Dalston.RC1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
server:
port: 8888
spring:
cloud:
config:
server:
git:
uri: https://github.com/xxxxxx/spring-config-repo.git
consul:
host: consul
port: 8500
enabled: true
discovery:
enabled: true
register: true
service-name: configservice
spring:
application:
name: config-server
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-all</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Dalston.RC1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
spring:
application:
name: myservice
cloud:
config:
fail-fast: true
retry:
max-attempts: 20
initial-interval: 3000
enabled: true
discovery:
enabled: true
service-id: configserver
consul:
host: localhost
port: 8500
discovery:
enabled: true
register: true
service-name: myservice
server:
port: 8081
application.yml
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-discovery</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Dalston.RC1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
server:
port: 8888
spring:
cloud:
config:
server:
git:
uri: https://github.com/xxxxxx/spring-config-repo.git
consul:
host: consul
port: 8500
enabled: true
discovery:
enabled: true
register: true
service-name: configservice
spring:
application:
name: config-server
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-all</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Dalston.RC1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
spring:
application:
name: myservice
cloud:
config:
fail-fast: true
retry:
max-attempts: 20
initial-interval: 3000
enabled: true
discovery:
enabled: true
service-id: configserver
consul:
host: localhost
port: 8500
discovery:
enabled: true
register: true
service-name: myservice
server:
port: 8081
MyServiceApplication.java
@EnableConfigServer
@EnableDiscoveryClient
@SpringBootApplication
public class ConfigServiceApplication {
public static void main(String[] args) {
SpringApplication.run(ConfigServiceApplication.class, args);
}
}
@EnableDiscoveryClient
@SpringBootApplication
public class MyServiceApplication {
public static void main(String[] args) {
SpringApplication.run(ApplePaymentServiceApplication.class, args);
}
}
但是在这个jar的启动过程中,它无法找到配置服务器,而是依赖于默认的uri。
这是相关的启动日志部分
2017-03-28 00:40:20.407 WARN 99123 --- [ main] lientConfigServiceBootstrapConfiguration : No instances found of configserver (configserver)
2017-03-28 00:40:20.551 INFO 99123 --- [ main] b.c.PropertySourceBootstrapConfiguration : Located property source: CompositePropertySource [name='consul', propertySources= . [ConsulPropertySource [name='config/myservice/'], ConsulPropertySource [name='config/application/']]]
2017-03-28 00:40:20.587 INFO 99123 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at: http://localhost:8888
2017-03-28 00:40:21.831 INFO 99123 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Located environment: name=myservice, profiles=[default], label=null, version=null, state=null
2017-03-28 00:40:21.832 INFO 99123 --- [ main] b.c.PropertySourceBootstrapConfiguration : Located property source: CompositePropertySource [name='configService', propertySources=[MapPropertySource [name='https://github.com/xxxxx/spring-config-repo.git/myservice.yml'], MapPropertySource [name='https://github.com/xxxxx/spring-config-repo.git/application.yml']]]
2017-03-28 00:40:21.841 INFO 99123 --- [ main] c.h.MyServiceApplication : No active profile set, falling back to default profiles: default
我从各种示例中修改了许多不同的选项,例如
有人能指出我可能遗漏了什么吗?
任何指向可访问正确应用程序/引导文件的工作示例的指针都将非常有帮助
PS:我为问题中的信息过载道歉。其中一些可能不相关,但我想提供尽可能多的信息,以便有人能够发现他们以前遇到过的问题。您正在尝试查找
configserver
,但它已注册为configservice
您正在尝试查找configserver
,但是它注册为configservice
谢谢spencer。我想我做了相当多的修补,留下了一些不匹配的名称,甚至没有注意到这一点。我现在工作很好,我想我有。我认为将复选标记切换为绿色就可以了。解决方案成功后,我第一件事就是这样做了。:)除此之外,我还需要做什么?我不知道“将复选标记切换为绿色”是什么意思。什么复选框和哪里?谢谢spencer。我想我做了相当多的修补,留下了一些不匹配的名称,甚至没有注意到这一点。我现在工作很好,我想我有。我认为将复选标记切换为绿色就可以了。解决方案成功后,我第一件事就是这样做了。:)除此之外,我还需要做什么?我不知道“将复选标记切换为绿色”是什么意思。什么复选框和在哪里?