当我加入spring-batch-integration
,spring-integration-file
和spring-integration-sftp
时,会产生LocationAwareLogger异常。当我删除它,一切都很好。在Maven项目中也有这些确切的依赖项对我来说很好。
Exception in thread "main" java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;Ljava/lang/Throwable;)V
at org.apache.commons.logging.impl.SLF4JLocationAwareLog.debug(SLF4JLocationAwareLog.java:133)
at org.apache.commons.configuration.ConfigurationUtils.locate(ConfigurationUtils.java:523)
at org.apache.commons.configuration.AbstractFileConfiguration.load(AbstractFileConfiguration.java:213)
at org.apache.commons.configuration.AbstractFileConfiguration.load(AbstractFileConfiguration.java:197)
at org.apache.commons.configuration.AbstractFileConfiguration.<init>(AbstractFileConfiguration.java:142)
at org.apache.commons.configuration.PropertiesConfiguration.<init>(PropertiesConfiguration.java:237) `spring-integration-sftp`
at com.example.Main.main(Main.java:27)
这一行出错:
final AbstractApplicationContext context = new ClassPathXmlApplicationContext(
"classpath:spring/batch/config/context.xml",
"classpath:spring/batch/config/spring-batch.xml",
"classpath:spring/batch/config/spring-integration.xml");
我的依赖关系是:
versions += [
mavenWagonHttp: "2.2",
kohlsCodingStandards: "2.0.15",
log4j:"1.2.16",
spring:"3.2.2.RELEASE",
springBatch:"2.2.0.RELEASE",
springBatchIntegration:"1.2.2.RELEASE",
springIntegrationFile:"2.1.0.RELEASE",
springIntegrationSFTP:"2.1.0.RELEASE",
mysqlDriver:"5.1.25",
junit:"4.11",
commonsConfiguration:"1.6",
apacheCommonsLang3:"3.3.2",
slf4jLog4j12:"1.5.6"
]
libs += [
mavenWagonHttp: "org.apache.maven.wagon:wagon-http:$versions.mavenWagonHttp",
kohlsCodingStandards: "com.kohls.services:services-coding-standards:$versions.kohlsCodingStandards",
log4j:"log4j:log4j:$versions.log4j",
spring:"org.springframework:spring-core:$versions.spring",
springBatch:"org.springframework.batch:spring-batch-core:$versions.springBatch",
springBatchInfrastructure:"org.springframework.batch:spring-batch-infrastructure:$versions.springBatch",
springBatchIntegration:"org.springframework.batch:spring-batch-integration:$versions.springBatchIntegration",
springIntegrationFile:"org.springframework.integration:spring-integration-file:$versions.springIntegrationFile",
springIntegrationSFTP:"org.springframework.integration:spring-integration-sftp:$versions.springIntegrationSFTP",
springBatchTest:"org.springframework.batch:spring-batch-test:$versions.springBatch",
junit:"junit:junit:$versions.junit",
log4j:"log4j:log4j:$versions.log4j",
commonsConfiguration:"commons-configuration:commons-configuration:$versions.commonsConfiguration",
apacheCommonsLang3:"org.apache.commons:commons-lang3:$versions.apacheCommonsLang3",
slf4jLog4j12:"org.slf4j:slf4j-log4j12:$versions.slf4jLog4j12"
]
dependencies {
compile([
libs.mavenWagonHttp,
libs.kohlsCodingStandards,
libs.log4j,
libs.spring,
libs.springBatch,
libs.springBatchInfrastructure,
libs.springBatchIntegration,
libs.springIntegrationFile,
libs.springIntegrationSFTP,
libs.springBatchTest,
libs.junit,
libs.commonsConfiguration,
libs.apacheCommonsLang3,
libs.slf4jLog4j12
])
compile fileTree(dir: 'lib', include: ['*.jar'])
}
答案 0 :(得分:0)
所以这就是我想出来的。我强迫slf4j使用版本1.5.8,它似乎工作。如果有其他方法可以让我知道,否则我明天会将此标记为最佳答案。
我将此添加到build.gradle
configurations.all {
resolutionStrategy {
force 'org.slf4j:slf4j-log4j12:1.5.8','org.slf4j:slf4j-api:1.5.8'
}
}