Spring Integration JDBC元数据存储

时间:2018-06-04 21:19:45

标签: spring jdbc spring-integration metadata

我正在使用Spring Integration来读取文件FileReadingMessageSource,为了避免同一个文件被读取两次(或其他并发应用程序也读取它),我使用的是FileSystemPersistentAcceptOnceFileListFilter

一切运行良好,它会在DB(MySQL)中保持文件的状态。 问题是:当我尝试两次读取同一个文件时,我得到一个例外:

org.springframework.core.convert.support.DefaultConversionService.getSharedInstance()Lorg/springframework/core/convert/ConversionService;

有没有人面对同样的事情? 谢谢!

详细例外:

SEVERE: java.lang.NoSuchMethodError: org.springframework.core.convert.support.DefaultConversionService.getSharedInstance()Lorg/springframework/core/convert/ConversionService;
    at org.springframework.jdbc.core.SingleColumnRowMapper.<init>(SingleColumnRowMapper.java:53)
    at org.springframework.jdbc.core.JdbcTemplate.getSingleColumnRowMapper(JdbcTemplate.java:1291)
    at org.springframework.jdbc.core.JdbcTemplate.queryForObject(JdbcTemplate.java:797)
    at org.springframework.integration.jdbc.metadata.JdbcMetadataStore.putIfAbsent(JdbcMetadataStore.java:134)
    at org.springframework.integration.file.filters.AbstractPersistentAcceptOnceFileListFilter.accept(AbstractPersistentAcceptOnceFileListFilter.java:77)
    at org.springframework.integration.file.filters.AbstractFileListFilter.filterFiles(AbstractFileListFilter.java:40)
    at org.springframework.integration.file.filters.CompositeFileListFilter.filterFiles(CompositeFileListFilter.java:108)
    at org.springframework.integration.file.DefaultDirectoryScanner.listFiles(DefaultDirectoryScanner.java:86)
    at org.springframework.integration.file.FileReadingMessageSource.scanInputDirectory(FileReadingMessageSource.java:293)
    at org.springframework.integration.file.FileReadingMessageSource.receive(FileReadingMessageSource.java:272)
    at org.springframework.integration.endpoint.SourcePollingChannelAdapter.receiveMessage(SourcePollingChannelAdapter.java:175)
    at org.springframework.integration.endpoint.AbstractPollingEndpoint.doPoll(AbstractPollingEndpoint.java:224)
    at org.springframework.integration.endpoint.AbstractPollingEndpoint.access$000(AbstractPollingEndpoint.java:57)
    at org.springframework.integration.endpoint.AbstractPollingEndpoint$1.call(AbstractPollingEndpoint.java:176)
    at org.springframework.integration.endpoint.AbstractPollingEndpoint$1.call(AbstractPollingEndpoint.java:173)
    at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller$1.run(AbstractPollingEndpoint.java:330)
    at org.springframework.integration.util.ErrorHandlingTaskExecutor$1.run(ErrorHandlingTaskExecutor.java:55)
    at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:50)
    at org.springframework.integration.util.ErrorHandlingTaskExecutor.execute(ErrorHandlingTaskExecutor.java:51)
    at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller.run(AbstractPollingEndpoint.java:324)
    at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
    at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:514)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:299)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
    at java.base/java.lang.Thread.run(Thread.java:844)

2 个答案:

答案 0 :(得分:2)

java.lang.NoSuchMethodError: org.springframework.core.convert.support.DefaultConversionService.getSharedInstance()Lorg/springframework/core/convert/ConversionService;表示您使用不兼容的Spring Integration和Spring Framework版本。对于Spring Integration,您应该只依赖于传递依赖。或者甚至更好地使用Spring Boot依赖管理。

答案 1 :(得分:1)

  • 是的,对我来说这也是依赖性问题。当我在项目目录中看到库列表时,版本冲突。
  • 我在项目中同时使用Spring-Security(4.2.5)和Spring框架(4.2.5)。
  • Maven正在下载“ spring-jdbc” “ spring-tx” 依赖项 (4.3.15) 版本的库。
    其余所有依赖项默认为4.2.5。

  • 所以我在pom.xml中手动将了 “ spring-jdbc”的maven依赖项添加到(4.2.5)解决了该问题