Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

classpath包含中文时,无法找到配置文件 #56

Open
cwt9562 opened this issue Jan 23, 2018 · 0 comments
Open

classpath包含中文时,无法找到配置文件 #56

cwt9562 opened this issue Jan 23, 2018 · 0 comments

Comments

@cwt9562
Copy link

cwt9562 commented Jan 23, 2018

我的项目的目录有中文,在org.apdplat.word.util.AutoDetector#loadClasspathResource这个方法中,取到的URL类的path是做了转义的,如/D:/svn/%e8%a1%8c%e6%94%bf%e6%89%a7%e6%b3%95/lfxj-provider-showcase/target/classes/custom_dic.txt
此时直接url.getFile()出来的File是无法找到的
需要先进行java.net.URLDecoder.decode()

完整的日志

2018-01-23 13:35:05.531 INFO 8544 --- [ main] org.apdplat.word.util.AutoDetector : 开始加载资源
2018-01-23 13:35:05.531 INFO 8544 --- [ main] org.apdplat.word.util.AutoDetector : classpath:custom_dic.txt,classpath:punctuation.txt,classpath:part_of_speech_dic.txt,classpath:word_synonym.txt,classpath:word_antonym.txt
2018-01-23 13:35:05.533 INFO 8544 --- [ main] org.apdplat.word.util.AutoDetector : 类路径资源:custom_dic.txt
2018-01-23 13:35:05.534 INFO 8544 --- [ main] org.apdplat.word.util.AutoDetector : 类路径资源URL:file:/D:/svn/%e8%a1%8c%e6%94%bf%e6%89%a7%e6%b3%95/001_%e5%bc%80%e5%8f%91%e5%ba%93/002_%e5%b7%a5%e7%a8%8b%e8%bf%87%e7%a8%8b%e5%ba%93/003_%e7%bc%96%e7%a0%81/lfxj/lfxj-provider/lfxj-provider-showcase/target/classes/custom_dic.txt
2018-01-23 13:35:05.534 INFO 8544 --- [ main] org.apdplat.word.util.AutoDetector : 加载资源:D:\svn%e8%a1%8c%e6%94%bf%e6%89%a7%e6%b3%95\001_%e5%bc%80%e5%8f%91%e5%ba%93\002_%e5%b7%a5%e7%a8%8b%e8%bf%87%e7%a8%8b%e5%ba%93\003_%e7%bc%96%e7%a0%81\lfxj\lfxj-provider\lfxj-provider-showcase\target\classes\custom_dic.txt
2018-01-23 13:35:05.546 ERROR 8544 --- [ main] org.apdplat.word.util.AutoDetector : 加载资源失败:D:\svn%e8%a1%8c%e6%94%bf%e6%89%a7%e6%b3%95\001_%e5%bc%80%e5%8f%91%e5%ba%93\002_%e5%b7%a5%e7%a8%8b%e8%bf%87%e7%a8%8b%e5%ba%93\003_%e7%bc%96%e7%a0%81\lfxj\lfxj-provider\lfxj-provider-showcase\target\classes\custom_dic.txt

java.io.FileNotFoundException: D:\svn%e8%a1%8c%e6%94%bf%e6%89%a7%e6%b3%95\001_%e5%bc%80%e5%8f%91%e5%ba%93\002_%e5%b7%a5%e7%a8%8b%e8%bf%87%e7%a8%8b%e5%ba%93\003_%e7%bc%96%e7%a0%81\lfxj\lfxj-provider\lfxj-provider-showcase\target\classes\custom_dic.txt (系统找不到指定的路径。)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(FileInputStream.java:195)
at java.io.FileInputStream.(FileInputStream.java:138)
at java.io.FileInputStream.(FileInputStream.java:93)
at org.apdplat.word.util.AutoDetector.load(AutoDetector.java:354)
at org.apdplat.word.util.AutoDetector.loadClasspathResource(AutoDetector.java:133)
at org.apdplat.word.util.AutoDetector.loadAndWatch(AutoDetector.java:87)
at org.apdplat.word.dictionary.DictionaryFactory$DictionaryHolder.reload(DictionaryFactory.java:83)
at org.apdplat.word.dictionary.DictionaryFactory$DictionaryHolder.(DictionaryFactory.java:80)
at org.apdplat.word.dictionary.DictionaryFactory.getDictionary(DictionaryFactory.java:61)
at org.apdplat.word.segmentation.impl.AbstractSegmentation.(AbstractSegmentation.java:54)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at org.apdplat.word.segmentation.SegmentationFactory.getSegmentation(SegmentationFactory.java:45)
at com.linewell.zhzf.lfxj.provider.showcase.segmenter.word.WordSegmenterService.afterPropertiesSet(WordSegmenterService.java:22)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:120)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:98)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:116)
at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:83)
at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:189)
at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:131)
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:230)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:228)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:287)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:289)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:247)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant