Skip to content

[Spring-boot] Slf4j Logger implementations conflict between maven and spring boot #8

@HomeOfTheWizard

Description

@HomeOfTheWizard

In the class SpringHelper in order to start the spring container and get the list of beans required by the project,
when using spring-boot as dependency

                .resourceLoader(new DefaultResourceLoader(classLoader))
                .sources(configClasses.toArray(new Class[0]))
                .properties(loadApplicationProperties())
                .run();

instead of spring,

var applicationContext = new AnnotationConfigApplicationContext();
        if(applicationPropertiesFile.exists()) {
            var resourcePropertyFile = createResourceFromPropertyFile(applicationPropertiesFile);
            applicationContext.getEnvironment().getPropertySources().addFirst(resourcePropertyFile);
        }
        applicationContext.register(configClasses.toArray(new Class[0]));
        applicationContext.refresh();

we have a conflict of Slf4j implementations of spring and maven

[INFO] [ERROR] Failed to execute goal com.homeofthewizard:spring-bridge-maven-plugin:1.0-SNAPSHOT:generate (generate) on project meeting-maven-plugin: Execution generate of goal com.homeofthewizard:spring-bridge-maven-plugin:1.0-SNAPSHOT:generate failed: LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Either remove Logback or the competing implementation (class org.slf4j.impl.MavenSimpleLoggerFactory loaded from file:/snap/intellij-idea-ultimate/510/plugins/maven/lib/maven3/lib/maven-slf4j-provider-3.9.6.jar). If you are using WebLogic you will need to add 'org.slf4j' to prefer-application-packages in WEB-INF/weblogic.xml: org.slf4j.impl.MavenSimpleLoggerFactory -> [Help 1]

We have to either resolve it on the project dependency level or the classloader given to the SpringBootBuilder.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions