Comments (12)
You'll need to describe your setup a bit more, because when I run, the node name is the hostname of the machine. If you can't resolve hostnames, maybe we should apply spring.cloud.consul.discovery.preferIpAddress
here and choose.
from spring-cloud-consul.
@gitpg you can now use spring.cloud.consul.discovery.preferIpAddress=true
.
from spring-cloud-consul.
Good solution, well done! Thanks
from spring-cloud-consul.
@spencergibb Is there a milestone repository that I can grab this fix from?
from spring-cloud-consul.
@arun0009 there has not been another milestone yet, but there is a snapshot in this repo:
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>http://repo.spring.io/libs-snapshot-local</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
at version 1.0.0.BUILD-SNAPSHOT
.
from spring-cloud-consul.
Thanks @spencergibb
I tried to update to BUILD-SNAPSHOT but now I get this exception:
Exception in thread "main" java.lang.IllegalStateException: Error processing condition on org.springframework.cloud.consul.ConsulAutoConfiguration.consulProperties
even with
config:
enabled: false
from spring-cloud-consul.
Can you give me more stack trace? The one line doesn't help.
from spring-cloud-consul.
| java.lang.reflect.InvocationTargetException | at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) | at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) | at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) | at java.lang.reflect.Method.invoke(Method.java:497) | at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:53) | at java.lang.Thread.run(Thread.java:745) | Caused by: java.lang.IllegalStateException: Error processing condition on org.springframework.cloud.consul.ConsulAutoConfiguration.consulProperties | at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:58) | at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:102) | at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForBeanMethod(ConfigurationClassBeanDefinitionReader.java:190) | at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:148) | at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:124) | at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:318) | at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:239) | at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:254) | at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:94) | at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:606) | at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:462) | at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) | at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686) | at org.springframework.boot.SpringApplication.run(SpringApplication.java:320) | at org.springframework.boot.SpringApplication.run(SpringApplication.java:957) | at org.springframework.boot.SpringApplication.run(SpringApplication.java:946) | at com.api.notifications.service.NotificationsApiClient.main(NotificationsApiClient.java:61) | ... 6 more | Caused by: java.lang.IllegalArgumentException: @ConditionalOnMissingBean annotations must specify at least one bean (type, name or annotation) | at org.springframework.util.Assert.isTrue(Assert.java:65) | at org.springframework.boot.autoconfigure.condition.OnBeanCondition$BeanSearchSpec.(OnBeanCondition.java:232) | at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchOutcome(OnBeanCondition.java:93) | at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:45)
from spring-cloud-consul.
@spencergibb more stack below with 1.0.0.BUILD-SNAPSHOT version
notificationsapiclient_1 | java.lang.IllegalStateException: Error processing condition on org.springframework.cloud.consul.ConsulAutoConfiguration.consulProperties notificationsapiclient_1 | at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:58) notificationsapiclient_1 | at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:102) notificationsapiclient_1 | at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForBeanMethod(ConfigurationClassBeanDefinitionReader.java:190) notificationsapiclient_1 | at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:148) notificationsapiclient_1 | at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:124) notificationsapiclient_1 | at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:318) notificationsapiclient_1 | at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:239) notificationsapiclient_1 | at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:254) notificationsapiclient_1 | at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:94) notificationsapiclient_1 | at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:606) notificationsapiclient_1 | at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:462) notificationsapiclient_1 | at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) notificationsapiclient_1 | at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686) notificationsapiclient_1 | at org.springframework.boot.SpringApplication.run(SpringApplication.java:320) notificationsapiclient_1 | at org.springframework.boot.SpringApplication.run(SpringApplication.java:957) notificationsapiclient_1 | at org.springframework.boot.SpringApplication.run(SpringApplication.java:946) notificationsapiclient_1 | at com.capitalone.api.notifications.service.NotificationsApiClient.main(NotificationsApiClient.java:61) notificationsapiclient_1 | at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) notificationsapiclient_1 | at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) notificationsapiclient_1 | at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) notificationsapiclient_1 | at java.lang.reflect.Method.invoke(Method.java:497) notificationsapiclient_1 | at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:53) notificationsapiclient_1 | at java.lang.Thread.run(Thread.java:745) notificationsapiclient_1 | Caused by: java.lang.IllegalArgumentException: @ConditionalOnMissingBean annotations must specify at least one bean (type, name or annotation) notificationsapiclient_1 | at org.springframework.util.Assert.isTrue(Assert.java:65) notificationsapiclient_1 | at org.springframework.boot.autoconfigure.condition.OnBeanCondition$BeanSearchSpec.(OnBeanCondition.java:232) notificationsapiclient_1 | at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchOutcome(OnBeanCondition.java:93) notificationsapiclient_1 | at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:45)
from spring-cloud-consul.
@arun0009 can you open a new issue, this one has been closed for a while.
from spring-cloud-consul.
I'm still new to Consul so I may have confused myself but when I saw the property preferIpAddress I assumed it was a switch between hostname vs ipAddress but it seems that it (also?) toggles between node names and the actual host providing the service.
The behavior is therefore very different when you run in an environment where the Consul server is not running on the same host as your services. If you have preferIpAddress false you basically get the wrong URIs.
Here is my very basic code:
@Autowired
private DiscoveryClient discoveryClient;
public void printInstances(String serviceName) throws Exception {
List<ServiceInstance> list = discoveryClient.getInstances(serviceName);
if (list == null) {
System.out.format("===== Null list returned for %s%n", serviceName);
} else {
System.out.format("===== Found %d instances of %s%n", list.size(), serviceName);
for (ServiceInstance serviceInstance : list) {
System.out.println(
serviceInstance.getServiceId() + " -- " + serviceInstance.getUri());
}
}
}
With preferIpAddress=false, the output (with hostnames simplified) is:
===== Found 2 instances of myservice
myservice -- http://consulhost:9010
myservice -- http://consulhost:9010
With preferIpAddress=true, the output is then:
===== Found 2 instances of myservice
myservice -- http://servicelhos1:9010
myservice -- http://servicehost2:9010
from spring-cloud-consul.
@GuiForget please open a new issue please, rather than comment on a closed issue.
from spring-cloud-consul.
Related Issues (20)
- Consul token query parameter deprecated in Consul 1.17 HOT 3
- Spring Cloud Consul does not work well with application context hierarchies and profiles
- Documentation - Clarify disabling of service registration
- Consul Admin Partition Support
- I hope to be able to load both key simultaneously
- The classloader/component “org.springframework.boot.loader.LaunchedURLClassLoader @ 0x800d8c18” occupies 621,015,112 (74.98%) bytes. The memory is accumulated in one instance of “java.lang.Object[]”, loaded by “<system class loader>”, which occupies 601,708,440 (72.65%) bytes. HOT 1
- Runtime reflection is not supported for public void org.springframework.cloud.consul.discovery.ConsulDiscoveryProperties.setHealthCheckPath
- Does the CVE-2022-22965 Vulnerability Affect spring-cloud-circuitbreaker? HOT 1
- How to use Consul as Config center for Spring Cloud Gateway
- Failed to bind properties under 'spring.cloud.consul.config' HOT 2
- Service Discovery not working when using WebClient with Consul HOT 1
- Springboot application restarting after getting warning -Error querying consul Key/Values for context HOT 1
- ConsulConfigProperties not caling init() method in spring-cloud-consul-config:3.1.2
- Depends on web to import a config
- Spring Boot 3.1 Compatibility? HOT 1
- Catalog Watch uses blocking queries incorrectly HOT 1
- Spring Cloud Consul not decrypting the tls key-store-password & certificate-password
- dependency cycle when Use my own ConsulServiceRegistry with spring-boot-starter-actuator HOT 3
- spring.config.import in DynamicPropertySource is not contributed using ConfigDataApplicationContextInitializer in tests
- Accessed Consul cluster's KV store with TLS and ACL enabled through code, but Spring Boot configuration failure
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spring-cloud-consul.