Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow consul config to use something other than spring.application.name #279

Closed
ummershervani opened this issue Feb 14, 2017 · 8 comments
Closed
Assignees
Milestone

Comments

@ummershervani
Copy link

In the docs its mentioned that. You can override the Config look up by setting up these params.
spring.cloud.config.name
spring.cloud.config.label
spring.cloud.config.profile.

But my application doesn't start as its trying to find folder named "Application Name" under consul. Which obviously doesn't exist and causes failure. Overriding option does'nt work.

What I am using
compile('org.springframework.cloud:spring-cloud-starter-consul-config')
compile('org.springframework.cloud:spring-cloud-starter-consul-discover

@spencergibb
Copy link
Member

spring.cloud.config. don't belong to spring cloud consul. Label doesn't make sense in consul (since it isn't a VCS). Can you explain more what you are trying to accomplish?

@ummershervani
Copy link
Author

@spencergibb , spring.cloud.config was the only thing I could find to override the defaults, you are right we dont use labels at all. Here is my requirement, In Consul our Key values are stored within a folder name which is different from my Application Name.

For instance here is an ex.
Here is what I have in BootStrap.
spring.application.name=Hello World
spring.cloud.config.name=configfoldername
spring.cloud.consul.host=http://localhost
spring.cloud.consul.port=8500
spring.cloud.config.enabled=true
spring.cloud.config.discovery.enabled=true
spring.cloud.consul.config.prefix=private

In Consul, Values are stored in under http://localhost:8500/ui/#/dc1/kv/private/consulfoldername/
So I want spring to go to this folder in Consul and load the properties for me. But Spring goes here http://localhost:8500/ui/#/dc1/kv/Hello World/ and throws an exception, because it always try and go with application name.

How would I achieve my requirement.

@spencergibb
Copy link
Member

The spring.cloud.consul.* properties should go in bootstrap.properties and it should access the application in /private/Hello World. There is currently no option to use something other than spring.application.name.

@spencergibb spencergibb self-assigned this Feb 15, 2017
@spencergibb spencergibb changed the title spring.cloud.config.name is ignored and spring boot app fails to start up Allow consul config to use something other than spring.application.name Feb 15, 2017
@spencergibb
Copy link
Member

Adds support for spring.cloud.consul.config.name

@spencergibb spencergibb added this to the 1.2.0.RC1 milestone Feb 15, 2017
@lightside786
Copy link

@spencergibb , thanks much.

@ummershervani
Copy link
Author

ummershervani commented Feb 15, 2017

@spencergibb , For the tests I am seeing the key values are not picked up by spring from consul. Since I have my DBUrl in consul, I am seeing below error.

Here is the stacktrace..

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration': Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration$$EnhancerBySpringCGLIB$$e482c933]: Constructor threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Tomcat.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.tomcat.jdbc.pool.DataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.NullPointerException
	at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:279)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1193)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1095)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:372)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:296)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1081)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:856)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542)
	at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737)
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:314)
	at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:120)
	at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:98)
	at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:116)

@spencergibb
Copy link
Member

@ummershervani that seems unrelated to this issue. Please open a new issue with instructions to reproduce or a sample project that reproduces the problem.

@ummershervani
Copy link
Author

@spencergibb , ofcouse it is a different issue. Not sure its very critical, problem disappeared when i include below in bootstrap properties under test.resources. I will get one issue open when I get in to root cause. I would assume this should have picked up from bootstarp.properties under main.
spring.application.name="appname"
spring.cloud.consul.config.prefix=private

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants