HomeOfTheWizard / spring-bridge-maven-plugin

A maven plugin that enables the usage of spring libraries in the development of other maven plugins
1 stars 0 forks source link

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

Open HomeOfTheWizard opened 1 month ago

HomeOfTheWizard commented 1 month ago

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.

HomeOfTheWizard commented 1 month ago

blocking https://github.com/HomeOfTheWizard/spring-bridge-maven-plugin/issues/3