Comment mettre en place le Printemps de Démarrage et log4j2 correctement?
Comment puis-je faire Printemps connecter correctement via log4j2
avec les autres dépendances que j'ai (Hibernate, Netty, Mina, etc.)?
J'ai essayé beaucoup de différentes amincit et de la dépendance des combinaisons. Mais j'ai peut que le Printemps pour se connecter et rien d'autre, ou de tout mais le Printemps.
Avec tous avec des dépendances de journalisation correctement (mais le Printemps), je reçois le message d'erreur suivant:
java.lang.NoSuchMethodError: org.apache.logging.log4j.core.config.ConfigurationFactory.getConfiguration(Lorg/apache/logging/log4j/core/config/ConfigurationSource;)Lorg/apache/logging/log4j/core/config/Configuration;
at org.springframework.boot.logging.log4j2.Log4J2LoggingSystem.loadConfiguration(Log4J2LoggingSystem.java:167)
at org.springframework.boot.logging.log4j2.Log4J2LoggingSystem.loadDefaults(Log4J2LoggingSystem.java:150)
at org.springframework.boot.logging.AbstractLoggingSystem.initializeWithConventions(AbstractLoggingSystem.java:75)
at org.springframework.boot.logging.AbstractLoggingSystem.initialize(AbstractLoggingSystem.java:50)
at org.springframework.boot.logging.log4j2.Log4J2LoggingSystem.initialize(Log4J2LoggingSystem.java:140)
at org.springframework.boot.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:277)
at org.springframework.boot.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:255)
at org.springframework.boot.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:224)
at org.springframework.boot.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:200)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:166)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:138)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:121)
at org.springframework.boot.context.event.EventPublishingRunListener.publishEvent(EventPublishingRunListener.java:111)
at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:65)
at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54)
at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:329)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:306)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1185)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1174)
at com.myproject.MyProject.main(MyProject.java:XX)
C'est mon build.gradle
dépendances
dependencies {
//FIX engine
compile 'org.quickfixj:quickfixj-all:1.6.2'
compile 'org.apache.mina:mina-core:2.0.16'
//Web API
compile ('org.springframework.boot:spring-boot-starter-web:1.4.1.RELEASE') {
//Remove default Spring loggers (where logback takes precedence)
exclude module: 'spring-boot-starter-logging'
}
//Logging
compile 'org.apache.logging.log4j:log4j-api:2.7'
compile 'org.apache.logging.log4j:log4j-core:2.7'
compile 'commons-logging:commons-logging:1.2' //for Spring logging
compile 'org.apache.logging.log4j:log4j-web:2.7' //for Spring logging
compile 'org.apache.logging.log4j:log4j-slf4j-impl:2.7' //for Hibernate logging
//ORM and Database Driver
compile 'org.hibernate:hibernate-core:5.2.4.Final'
compile 'org.postgresql:postgresql:9.4.1209'
//Key-value store
compile 'biz.paluch.redis:lettuce:4.1.2.Final'
//Testing
//The Groovy language
compile 'org.codehaus.groovy:groovy-all:2.4.6'
//Spock testing framework
testCompile 'org.spockframework:spock-core:1.0-groovy-2.4'
}
Alors, se débarrasser de mon journalisation des dépendances et de l'ajout de la dépendance au ci-dessous:
compile 'org.springframework.boot:spring-boot-starter-log4j2:1.4.1.RELEASE'
Printemps de l'enregistrement du travail, mais le deps journalisation ne sera pas.
C'est le main
méthode (rien de spécial)
public static void main(String[] args) {
//Fine tune a few logging settings so they don't log with TRACE or DEBUG levels.
Configurator.setLevel("org.hibernate", Level.ERROR);
Configurator.setLevel("org.jboss", Level.ERROR);
Configurator.setLevel("org.apache.mina", Level.ERROR);
Configurator.setLevel("io.netty", Level.ERROR);
Configurator.setLevel("quickfix.mina", Level.WARN);
Configurator.setLevel("com.lambdaworks", Level.WARN);
//...
logger.info("FIX Controller started. Loading the API.");
SpringApplication.run(MyProject.class, args);
}
Donc encore une fois, comment puis-je obtenir de Printemps à se connecter correctement via log4j2
avec les autres dépendances que j'ai?
OriginalL'auteur sargas | 2016-11-02
Vous devez vous connecter pour publier un commentaire.
Printemps de Démarrage 1.4.1 est construit et soutient de Log4J 2.6, mais vous essayez d'utiliser 2.7. Malheureusement, cela ne fonctionne pas comme il y a une rupture de l'API changement de 2.7 qui a été fait dans ce commit. C'est la cause de la
NoSuchMethodError
que vous voyez.De revenir à Log4J2 2.6.2 devrait résoudre le problème. Sinon, vous pouvez mettre à niveau vers le Printemps de Démarrage 1.5 qui utilise Log4J 2.7.
log4j2
dépendances fixe! Je vous remercie. Je pense que leorg.apache.logging.log4j.core.config.ConfigurationFactory.getConfiguration
méthode eststatic
en 2.6, mais pas en 2.7, brisant ainsi l'API.Printemps de Démarrage 1.5.1 est sorti! printemps.io/blog/2017/01/30/spring-boot-1-5-1-publié
Oui! en mettant de 2,7 pour le log4j dépendances, je n'ai pas d'erreurs 🙂
La mise à niveau vers SpringBoot 1.4.x pour SpringBoot 1.5.x a fonctionné!!!
OriginalL'auteur Andy Wilkinson