[
https://issues.apache.org/jira/browse/CAMEL-21341?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17888659#comment-17888659
]
carsten madsen commented on CAMEL-21341:
----------------------------------------
I can not do the @ImportResource annotation in the Spring Boot main class, it
must be controlled by a profile.
Is
{code:java}
public static class XmlConfigInitializer implements
ApplicationContextInitializer<GenericApplicationContext> {
@Override
public void initialize(GenericApplicationContext context) {
String[] activeProfiles = context.getEnvironment()
.getActiveProfiles();
for (String profile : activeProfiles) {
if ("xml".equals(profile)) {
XmlBeanDefinitionReader xmlReader = new
XmlBeanDefinitionReader(
context);
xmlReader.loadBeanDefinitions(
new
ClassPathResource("XmlConfigCircular.xml"));
}
}
}
}
{code}
A safe alternative to
{code:java}
@Configuration
@Profile({ "xml" })
@ImportResource({ "classpath:XmlConfigCircular.xml" })
class XmlConfiguration
{code}
?
> Cycle between camel and
> org.apache.camel.impl.health.DefaultHealthCheckRegistry
> -------------------------------------------------------------------------------
>
> Key: CAMEL-21341
> URL: https://issues.apache.org/jira/browse/CAMEL-21341
> Project: Camel
> Issue Type: Bug
> Components: camel-spring-boot
> Reporter: carsten madsen
> Priority: Minor
>
> The following will make spring boot 3.3.4/camel 4.8.0 report this cycle
> {color:#000000}camel{color}
> {color:#000000}↑ ↓{color}
> {color:#000000}org.apache.camel.impl.health.DefaultHealthCheckRegistry{color}
> {code:java}
> import org.junit.jupiter.api.Test;
> import org.springframework.boot.test.context.SpringBootTest;
> import org.springframework.context.annotation.Configuration;
> import org.springframework.context.annotation.ImportResource;
>
> @SpringBootTest
> class CamelCircularRef {
>
> @Test
> void testCamelConfig() {
> // assertThat(camelContext).isNotNull();
> }
>
> @Configuration
> @ImportResource("classpath:XmlConfigCircular.xml")
> static class TestConfig {
> }
> }
> {code}
> Content of XmlConfigCircular.xml:
> {code:xml}
> <beans xmlns="http://www.springframework.org/schema/beans"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:context="http://www.springframework.org/schema/context"
> xsi:schemaLocation="http://www.springframework.org/schema/context
> http://www.springframework.org/schema/context/spring-context.xsd
> http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans.xsd
> http://camel.apache.org/schema/spring
> http://camel.apache.org/schema/spring/camel-spring.xsd">
> <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
> </camelContext>
> </beans>
> {code}
> Is this a bug or a faulty configuration issue?
> Using spring.main.allow-circular-references=true does allow my application to
> run.
> Looks like CAMEL-17220
--
This message was sent by Atlassian Jira
(v8.20.10#820010)