Why ConditionEvaluationReportLoggingListener never invoked in failed context tests using ApplicationContextRunner? - spring-boot

Expected behavior
As a spring-boot developer
in order to diagnose failed context startup in tests using ApplicationContextRunner
I need ConditionEvaluationReportLoggingListener to print report as documented in
https://docs.spring.io/spring-boot/docs/2.3.6.RELEASE/reference/htmlsingle/#boot-features-test-autoconfig
The runner can also be used to display the ConditionEvaluationReport. The report can be printed at INFO or DEBUG level. The following example shows how to use the ConditionEvaluationReportLoggingListener to print the report in auto-configuration tests.
#Test
public void autoConfigTest {
ConditionEvaluationReportLoggingListener initializer = new ConditionEvaluationReportLoggingListener(
LogLevel.INFO);
ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withInitializer(initializer).run((context) -> {
// Do something...
});
}
In order to help me diagnose failures of test (in particular when context fails to be initialized), I need to get a report such as the following to understand whether my #ConditionalOnProperty logic is correct.
#Configuration
#ConditionalOnProperty(value= DynamicCatalogConstants.OPT_IN_PROPERTY)
#EnableConfigurationProperties
public class DynamicCatalogServiceAutoConfiguration {
[...]
20-11-2020 14:47:02.380 [main] DEBUG o.s.b.a.l.ConditionEvaluationReportLoggingListener.logAutoConfigurationReport -
============================
CONDITIONS EVALUATION REPORT
============================
Positive matches:
-----------------
DynamicCatalogServiceAutoConfiguration matched:
- #ConditionalOnProperty (osbcmdb.dynamic-catalog.enabled) matched (OnPropertyCondition)
Negative matches:
-----------------
None
Exclusions:
-----------
None
Unconditional classes:
----------------------
None
I'm using spring-boot 2.3.6.
Observed behavior
The condition report is not invoked when context fails to start
Instead of a condition report, only the following context init exception is displayed
20-11-2020 14:24:10.609 [main] WARN o.s.c.a.AnnotationConfigApplicationContext.refresh - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.support.BeanDefinitionOverrideException: Invalid bean definition with name 'dynamicCatalogService' defined in com.orange.oss.osbcmdb.catalog.DynamicCatalogServiceAutoConfigurationTest$SingleServiceDefinitionAnswerAutoConfig: Cannot register bean definition [Root bean: class [null]; scope=; abstract=false; lazyInit=null; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=dynamicCatalogServiceAutoConfigurationTest.SingleServiceDefinitionAnswerAutoConfig; factoryMethodName=dynamicCatalogService; initMethodName=null; destroyMethodName=(inferred); defined in com.orange.oss.osbcmdb.catalog.DynamicCatalogServiceAutoConfigurationTest$SingleServiceDefinitionAnswerAutoConfig] for bean 'dynamicCatalogService': There is already [Root bean: class [null]; scope=; abstract=false; lazyInit=null; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=dynamicCatalogServiceAutoConfiguration; factoryMethodName=dynamicCatalogService; initMethodName=null; destroyMethodName=(inferred); defined in com.orange.oss.osbcmdb.catalog.DynamicCatalogServiceAutoConfiguration] bound.
java.lang.IllegalStateException: Unstarted application context org.springframework.boot.test.context.assertj.AssertableApplicationContext[startupFailure=org.springframework.beans.factory.support.BeanDefinitionOverrideException] failed to start
at org.springframework.boot.test.context.assertj.AssertProviderApplicationContextInvocationHandler.getStartedApplicationContext(AssertProviderApplicationContextInvocationHandler.java:156)
at org.springframework.boot.test.context.assertj.AssertProviderApplicationContextInvocationHandler.invokeApplicationContextMethod(AssertProviderApplicationContextInvocationHandler.java:147)
at org.springframework.boot.test.context.assertj.AssertProviderApplicationContextInvocationHandler.invoke(AssertProviderApplicationContextInvocationHandler.java:85)
at com.sun.proxy.$Proxy20.getBean(Unknown Source)
at com.orange.oss.osbcmdb.catalog.DynamicCatalogServiceAutoConfigurationTest.lambda$dynamicServiceLoadWhenOptInProperty$2(DynamicCatalogServiceAutoConfigurationTest.java:84)
Sample code:
#Test
void dynamicServiceLoadWhenOptInProperty() {
ConditionEvaluationReportLoggingListener initializer = new ConditionEvaluationReportLoggingListener(LogLevel.INFO);
ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withInitializer(initializer)
.withConfiguration(AutoConfigurations.of(
SingleServiceDefinitionAnswerAutoConfig.class,
DynamicCatalogServiceAutoConfiguration.class,
MockedMaintenanceInfoFormatterServiceConfig.class
))
.withPropertyValues(DynamicCatalogConstants.OPT_IN_PROPERTY + "=true");
contextRunner.run(context -> {
Catalog catalog = context.getBean(Catalog.class);
assertThat(catalog.getServiceDefinitions()).isNotEmpty();
assertThat(context).hasSingleBean(Catalog.class);
});
}
What I tried
The logging level is properly set to debug.
Stepping into the debugger, it seems that the ConditionEvaluationReportLoggingListener is never invoked for event notifications.
I however managed to manually trigger the condition report printed by invoking it explicitly with the debugger:
Should I submit an issue on the springboot repo ?

The limitation was acknowledged by the spring-boot team in https://github.com/spring-projects/spring-boot/issues/24235
Hopefully a future improvement will fix this problem.

Related

how to disable autoconfiguration in integration test?

I am trying this:
#SpringBootTest(
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
)
#EnableAutoConfiguration(
exclude = [
ReactiveOAuth2ClientAutoConfiguration::class,
ReactiveOAuth2ResourceServerAutoConfiguration::class,
]
)
#ActiveProfiles("testcontainers")
internal class RecordIntegrationTest {
#Test
fun contextLoads() {}
}
With testcontainers profile in application.yml:
spring:
config.activate.on-profile: testcontainers
r2dbc.url: r2dbc:tc:postgresql:///databasename?TC_IMAGE_TAG=13.2
flyway:
enabled: false
But then it tries to create repositories twice (and potentially other beans as well):
java.lang.IllegalStateException: Failed to load ApplicationContext
...
Caused by: org.springframework.beans.factory.support.BeanDefinitionOverrideException: Invalid bean definition with name 'recordRepository' defined in com.example.RecordRepository defined in #EnableR2dbcRepositories declared on R2dbcRepositoriesAutoConfigureRegistrar.EnableR2dbcRepositoriesConfiguration: Cannot register bean definition [Root bean: class [org.springframework.data.r2dbc.repository.support.R2dbcRepositoryFactoryBean]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in com.example.RecordRepository defined in #EnableR2dbcRepositories declared on R2dbcRepositoriesAutoConfigureRegistrar.EnableR2dbcRepositoriesConfiguration] for bean 'recordRepository': There is already [Root bean: class [org.springframework.data.r2dbc.repository.support.R2dbcRepositoryFactoryBean]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in com.example.RecordRepository defined in #EnableR2dbcRepositories declared on R2dbcRepositoriesAutoConfigureRegistrar.EnableR2dbcRepositoriesConfiguration] bound.
UPDATE
Found out that the test runs fine when I move it to the root package
src/test/kotlin/com/example/backend
But it fails when I put it in the package
`src/test/kotlin/com/example/backend/subfolder`
UPDATE 2
I figured out that if a repository defined under src/main/kotlin is in the same package as the integration test that exception shows up.
E.g.:
data class X(#Id id: Long? = null)
// src/main/kotlin/com/example/x/XRepository.kt
interface XRepository : CoroutineCrudRepository<X, Long> {}
This test fails with the above exception:
// src/test/kotlin/com/example/x/XIntegrationTest.kt
#SpringBootTest(classes = [BackendApplication::class])
#EnableAutoConfiguration(
exclude = [
ReactiveOAuth2ClientAutoConfiguration::class,
ReactiveOAuth2ResourceServerAutoConfiguration::class,
]
)
#ActiveProfiles("testcontainers")
internal class XIntegrationTest {
#Test
fun contextLoads() {
}
}
Deleting the repository or moving the integration test to a different package works fine.
Include DataSourceAutoConfiguration in exclude block used by EnableR2dbcRepositories which disables the checking of datasource while starting up your integration test which is used by Repositories or you can configure the datasource to fix this issue.
The issue is basically due to the unavailability of datasource required by the repositories
Somewhere in your src/main/java you have a class that brings the annotation #EnableAutoConfiguration. This is the class that you want to exclude from your tests, when you have defined your own #EnableAutoConfiguration in some other class in test package.

Not able to execute DataJpaTest

I have a spring-data-jpa repository called TagRepository. My spring-boot version is 2.1.2. I am using H2 dependency with runtime scope and I intend to use it for both the application and integration testing. I want to write a DataJpaTest for the TagRepository. I have written the following code:
#RunWith(SpringRunner.class)
#EnableAutoConfiguration
#DataJpaTest
#ContextConfiguration(classes={TagRepository.class})
public class TagRepositoryTest {
#Autowired
private TestEntityManager testEntityManager;
#Autowired
private TagRepository tagRepository;
#Test
public void findByTagTest() {
Tag tag = new Tag("java");
testEntityManager.persistAndFlush(tag);
Optional<Tag> optionalTag = tagRepository.findByTag(tag.getTag());
if(!optionalTag.isPresent()) {
fail("Tag not found hence test failed");
}
assertThat(optionalTag.get()).isEqualTo(tag);
}
}
However, when I execute the test it says Application failed to start and I get following error:
Invalid bean definition with name 'tagRepository' defined in null: Cannot register bean definition [Root bean: class [org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] for bean 'tagRepository': There is already [Generic bean: class [com.upday.task.repository.TagRepository]; scope=singleton; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] bound.
The bean 'tagRepository', defined in null, could not be registered. A bean with that name has already been defined in null and overriding is disabled.
Action:
Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true
The test class itself resides in a different package than jpa repository.
Just remove
#ContextConfiguration(classes={TagRepository.class})
from your test.
It is meant for passing a custom #Configuration not a regular bean.
UPD:
When data jpa test and the repository under test resides in a different packages spring runner needed a little hint to scan classes from another place. Pointing out the application class via
#ContextConfiguration(classes={SpringBootApplication.class})
will extend the component scan scope and allow test environment to pick up additional beans.

The bean 'metaDataSourceAdvisor', defined in null, could not be registered

I've updated the Spring Boot version from 2.0.3 to 2.1.1 but I'm getting this:
***************************
APPLICATION FAILED TO START
***************************
Description:
The bean 'metaDataSourceAdvisor', defined in null, could not be registered. A bean with that name has already been defined in null and overriding is disabled.
Action:
Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true
I get the error - the problem is that defined in null is not really a good pointer where to look. I've seen this question but I'd actually prefer to keep disallowing overriding ambiguous beans.
Any ideas?
Log output
2019-01-06 07:33:39.282 INFO 29626 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2019-01-06 07:33:39.282 INFO 29626 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2019-01-06 07:33:39.912 INFO 29626 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
2019-01-06 07:33:39.997 INFO 29626 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 80ms. Found 23 repository interfaces.
2019-01-06 07:33:39.999 WARN 29626 --- [ restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.support.BeanDefinitionOverrideException: Invalid bean definition with name 'metaDataSourceAdvisor' defined in null: Cannot register bean definition [Root bean: class [org.springframework.security.access.intercept.aopalliance.MethodSecurityMetadataSourceAdvisor]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] for bean 'metaDataSourceAdvisor': There is already [Root bean: class [org.springframework.security.access.intercept.aopalliance.MethodSecurityMetadataSourceAdvisor]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] bound.
2019-01-06 07:33:40.008 INFO 29626 --- [ restartedMain] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-01-06 07:33:40.010 ERROR 29626 --- [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter :
Okay, I found the issue myself: I had #EnableGlobalMethodSecurity twice in my project:
#Configuration
#EnableWebSecurity
#EnableGlobalMethodSecurity(prePostEnabled = true) // <--
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
}
and
#SpringBootApplication
#EnableJpaRepositories(basePackages = {"mz.server.spring.repository"})
#EnableGlobalMethodSecurity(prePostEnabled = true, proxyTargetClass = true) // <--
#EntityScan(basePackages = "mz.server.hibernate.model")
#EnableTransactionManagement
#EnableScheduling
public class Application {
}
So that's a nice new Spring Boot feature I'd say.
Just watch out for unwanted duplicate annotations if you see this kind of error.
Expanding on the accepted answer, as per the release notes for Spring Boot 2.1
Bean overriding has been disabled by default to prevent a bean being accidentally overridden. If you are relying on overriding, you will need to set spring.main.allow-bean-definition-overriding to true.
So if you have used #EnableGlobalMethodSecurity more than once in your codebase and these beans are part of the same component scan then this annotation will attempt to create the metaDataSourceAdvisor bean more than once. This will throw an exception during initialization.
This will also apply to other auto configuration annotations that create beans. Make sure to only use their enabling annotations once.
Check if you have missed adding following annotations (whichever applicable)
#EnableJpaRepositories({"com.base.package"})
#EnableMongoRepositories({"com.base.package"})
This worked for me
I tried all these answers. But I noticed that error terminal says spring.main.allow-bean-definition-overriding=true in your properties. Just do it it worked for me.
Can help "clean" and "build" project in Gradle or Maven.

Spring-Boot disable load-on startup rabbitMQ

Why RabbitMQ is triggered or running while building the spring-boot jar.While running the Application.java or pom.xml.
i am able to see the following loggers
2016-07-01 16:40:04.334 INFO 7004 --- [ main] com.rabbit.App : No active profile set, falling back to default profiles: default
2016-07-01 16:40:04.391 INFO 7004 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#1da51a35: startup date [Fri Jul 01 16:40:04 CEST 2016]; root of context hierarchy
2016-07-01 16:40:05.331 INFO 7004 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'rabbitListenerContainerFactory' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=rabbitMqConfiguration; factoryMethodName=rabbitListenerContainerFactory; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/rabbit/messaging/configuration/RabbitMqConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=taskConsumerConfiguration; factoryMethodName=rabbitListenerContainerFactory; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/rabbit/messaging/configuration/TaskConsumerConfiguration.class]]
2016-07-01 16:40:05.334 INFO 7004 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'connectionFactory' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=rabbitMqConfiguration; factoryMethodName=connectionFactory; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/rabbit/messaging/configuration/RabbitMqConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=taskConsumerConfiguration; factoryMethodName=connectionFactory; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/rabbit/messaging/configuration/TaskConsumerConfiguration.class]]
2016-07-01 16:40:05.334 INFO 7004 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'jsonMessageConverter' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=rabbitMqConfiguration; factoryMethodName=jsonMessageConverter; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/rabbit/messaging/configuration/RabbitMqConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=taskConsumerConfiguration; factoryMethodName=jsonMessageConverter; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/rabbit/messaging/configuration/TaskConsumerConfiguration.class]]
2016-07-01 16:40:05.868 INFO 7004 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.amqp.rabbit.annotation.RabbitBootstrapConfiguration' of type [class org.springframework.amqp.rabbit.annotation.RabbitBootstrapConfiguration$$EnhancerBySpringCGLIB$$ad9295b0] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2016-07-01 16:40:06.657 INFO 7004 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
Is there any option to disable this?
While building the jar during test phase it throws following exception.
LifecycleProcessor with name 'lifecycleProcessor': using default [org.springframework.context.support.DefaultLifecycleProcessor#76dc36e5]
2016-06-30 15:10:32.989 WARN 21614 --- [cTaskExecutor-1] o.s.a.r.l.SimpleMessageListenerContainer : Consumer raised exception, processing can restart if the connection factory supports it
org.springframework.amqp.AmqpIOException: java.net.SocketTimeoutException: connect timed out
at org.springframework.amqp.rabbit.support.RabbitExceptionTranslator.convertRabbitAccessException(RabbitExceptionTranslator.java:67)
at
You get the log entry 'Overriding bean definition..' when you define a bean with that name more than once.
This leads to the question, which of the, at least two, beans do you use and how are they configured?
Set breakpoint(s) on the constructor(s) of the rabbitListenerContainerFactory bean and see which instances you are creating.
Looking up the stack trace may give you information about why this bean is created, so you can remove the duplicate from your spring configuration.
You can also add breakpoints, where the rabbit connection properties are set.
"connect timed out" also appears, when the given ip is wrong.
Anyway I would not recommend to set the properties in the build script, instead point to the property files on the command line, when you start the application. That allows you to use your build in different environments.
See howto-properties-and-configuration
Why it is throwing while building the jar?
You wrote you are setting the properties with a script during build.
This means that the tests are using those properties and now the tests are failing, may be because the rabbit mq server is not reachable with the provided properties or is not up.
As long as you are overriding beans, you do not really know which instance you use, so you dont really know which properties you use.
Try to log it out, than I am sure you will see....
You can't "lazy load" beans that implement SmartLifecycle (such as the listener container) because the context has to load the bean to call isAutoStartup() to see whether or not the bean should be started.
If the context is being loaded while "building the jar", you must have test cases that are using the beans. You can set autoStartup to false - but your tests will probably fail then.
You can skip running the tests with -DskipTests=true (maven) or -x test (gradle).
I have the same problem in my tests. I don't use rabbit and because the timeouts occur the tests duration increases.
As a simple workaround, you can disable the configuration of queues, exchanges etc. during tests using spring profiles.
Example:
Having the configuration that is disabled if the spring profile "no_rabbit" is present.
#Configuration
#Profile("!no_rabbit")
public class RabbitMQConfig {
#Bean
public Queue queue() {
return QueueBuilder.durable("NAMW").withArgument("x-message-ttl", 3600).build();
}
// more definitions of bean, exchanges etc.
}
Then, in the test simply add the profile "no_rabbit".
#RunWith(SpringRunner.class)
#ActiveProfiles({ "no_rabbit" })
public class TestClass {
...
}
The drawbacks of this approach is that you have to add the profile in every single test that don't uses rabbit. But for my case it's ok until I have a better solution.

Overriding the InfoEndpoint in Spring Cloud

Originally posted this as an issue in GitHub but might be better suited for this forum...
We are assigning some custom metadata values to our Spring Cloud services that are being registered in Eureka and we now need to have visibility to those values in the Eureka dashboard. I am trying to extend/override the /info endpoint so that our metadata is visible from the Eureka Dashboard which already provides hyperlinks to each registered service's /info endpoint. I had read that I could override the Boot autoconfigured InfoEndpoint by just adding my own version of that bean to the context. I am trying to test with the following configuration bean:
#Configuration
public class EndpointConfig {
#Bean
public InfoEndpoint infoEndpoint() throws Exception {
LinkedHashMap<String, Object> info = new LinkedHashMap<String, Object>();
info.put("name", "value");
return new InfoEndpoint(info);
}
}
When I run my service though and hit its /info endpoint I do not see this test value. I also see this in the log:
2015-04-17 14:54:23,910 main INFO DefaultListableBeanFactory - - - -
Overriding bean definition for bean 'infoEndpoint': replacing [Root
bean: class [null]; scope=; abstract=false; lazyInit=false;
autowireMode=3; dependencyCheck=0; autowireCandidate=true;
primary=false; factoryBeanName=endpointConfig;
factoryMethodName=infoEndpoint; initMethodName=null;
destroyMethodName=(inferred); defined in class path resource
[com/acme/ecom/items/config/EndpointConfig.class]] with [Root bean:
class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3;
dependencyCheck=0; autowireCandidate=true; primary=false;
factoryBeanName=org.springframework.cloud.autoconfigure.RefreshAutoConfiguration$InfoEndpointRebinderConfiguration;
factoryMethodName=infoEndpoint; initMethodName=null;
destroyMethodName=(inferred); defined in class path resource
[org/springframework/cloud/autoconfigure/RefreshAutoConfiguration$InfoEndpointRebinderConfiguration.class]]
It appears that my version of the infoEndpoint bean is being replaced with another bean coming from Spring cloud (in org/springframework/cloud/autoconfigure/RefreshAutoConfiguration$InfoEndpointRebinderConfiguration.class).
Am I reading this correctly? And if so how do I prevent it?
Thanks,
Bill
If you put your metadata in info.* e.g. info.myfoo=${eureka.instance.metadataMap.myfoo:none} it will show up in the default /info endpoint.
Don't know if this will actually help but I have this in my application.yml which I can see when I do /info on the service.
info:
component: Service Name
so when i hit the service with /info this is what i see:-
{
"component": "Service Name"
}
Hope this helps.

Resources