1
我想在具有java 1.6的語音開關上運行程序,但我無法更改該程序。運行使用java的彈簧整合文件1.6
@Bean
@InboundChannelAdapter(value = "fileInputChannel", poller = @Poller(fixedDelay = "5000"))
public MessageSource<File> fileReadingMessageSource() {
FileReadingMessageSource source = new FileReadingMessageSource();
source.setDirectory(new File(folderPath));
CompositeFileListFilter fileListFilter = new CompositeFileListFilter();
fileListFilter.addFilters(new IgnoreHiddenFileListFilter());
fileListFilter.addFilters(new FileSystemPersistentAcceptOnceFileListFilter(propertiesPersistingMetadataStore(),"cdrs"));
fileListFilter.addFilters(new RegexPatternFileListFilter(fileRegex));
// fileListFilter.addFilters(new LastModifiedFileListFilter()); // This is to confirm that the file did not change for the past 60 second
source.setFilter(fileListFilter);
return source;
}
,當我得到這個錯誤
Caused by: java.lang.NoClassDefFoundError: java/nio/file/StandardWatchEventKinds
at org.springframework.integration.file.FileReadingMessageSource$WatchEventType.<clinit>(FileReadingMessageSource.java:411) ~[spring-integration-file-4.3.5.RELEASE.jar!/:4.3.5.RELEASE]
at org.springframework.integration.file.FileReadingMessageSource.<init>(FileReadingMessageSource.java:117) ~[spring-integration-file-4.3.5.RELEASE.jar!/:4.3.5.RELEASE]
at org.springframework.integration.file.FileReadingMessageSource.<init>(FileReadingMessageSource.java:123) ~[spring-integration-file-4.3.5.RELEASE.jar!/:4.3.5.RELEASE]
at com.config.RootConfiguration.fileReadingMessageSource(RootConfiguration.java:84) ~[classes!/:0.0.1-SNAPSHOT]
at com.config.RootConfiguration$$EnhancerBySpringCGLIB$$3f678755.CGLIB$fileReadingMessageSource$2(<generated>) ~[classes!/:0.0.1-SNAPSHOT]
at com.config.RootConfiguration$$EnhancerBySpringCGLIB$$3f678755$$FastClassBySpringCGLIB$$22198f53.invoke(<generated>) ~[classes!/:0.0.1-SNAPSHOT]
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) ~[spring-core-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:356) ~[spring-context-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
at com.config.RootConfiguration$$EnhancerBySpringCGLIB$$3f678755.fileReadingMessageSource(<generated>) ~[classes!/:0.0.1-SNAPSHOT]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.6.0_36]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.6.0_36]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.6.0_36]
at java.lang.reflect.Method.invoke(Method.java:622) ~[na:1.6.0_36]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162) ~[spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
... 41 common frames omitted
Caused by: java.lang.ClassNotFoundException: java.nio.file.StandardWatchEventKinds
at java.net.URLClassLoader$1.run(URLClassLoader.java:217) ~[na:1.6.0_36]
at java.security.AccessController.doPrivileged(Native Method) ~[na:1.6.0_36]
at java.net.URLClassLoader.findClass(URLClassLoader.java:205) ~[na:1.6.0_36]
at java.lang.ClassLoader.loadClass(ClassLoader.java:323) ~[na:1.6.0_36]
at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:94) ~[filetail-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at java.lang.ClassLoader.loadClass(ClassLoader.java:268) ~[na:1.6.0_36]
... 55 common frames omitted
我可以停止使用NIO的手錶,因爲它與@UsesJava7
註釋,或者我應該實現自己的FileReadingMessageSource
現在
我試着設置** source.setUseWatchService(false); **但那不起作用 – Shahbour
Ugh;這是一個錯誤;手錶服務曾經是一個可選的(外部)類;它在4.3中作爲內部類被嵌入以避免一些配置問題。解決方法是回到4.2.12版本。如果你想跟蹤它,我打開了一個[JIRA問題](https://jira.spring.io/browse/INT-4185)。我們可能會在幾周內發佈4.3.6。 –
謝謝,我沒有複製粘貼代碼並刪除了手錶服務。當更新發布時,我將刪除克隆的類。 – Shahbour