2017-02-14 41 views
0

file structure如何導入配置文件在春季

Spring Config file

異常發送上下文初始化事件監聽器類org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanInitializationException實例:無法加載屬性;嵌套異常是java.io.FileNotFoundException:class pat h資源[WEB-INF/config/redis.properties]無法打開,因爲它不存在 位於org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer的.java:89) 在org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:284) 在org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:166) 在org.springframework .context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessor(AbstractApplicationContext.java:681) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicati onContext.java:523) 在org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:444) 在org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:326) 在有機springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4842) at org.apache.catalina.core.StandardContext.startInternal( StandardContext.java:5303) 在org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147) 在org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725) 的組織。 apache.catalina.core.ContainerBase.addChild(ContainerBase.java: 701) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1092) at org.apache.catalina。 startup.HostConfig $ DeployDirectory.run(HostConfig.java:1834) at java.util.concurrent.Executors $ RunnableAdapter.call(Executors.java:471) at java.util.concurrent.FutureTask.run(FutureTask.java: 262) 在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) 在java.util.concurrent.ThreadPoolExecutor中$ Worker.run(ThreadPoolExecutor.java:615) 在java.lang.Thread.run( Thread.java:744) 引起:java.io.FileNotFoundException:類路徑資源[WEB-INF/config/redis.properties]無法打開,因爲它不會在org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:172) 在org.springframework.core.io.support.EncodedResource.getInputStream(EncodedResource.java:153) 在組織存在 。 springframework.core.io.support.PropertiesLoaderUtils.fillProperties(PropertiesLoaderUtils.java:98) at org.springframework.core.io.support.PropertiesLoaderSupport.loadProperties(PropertiesLoaderSupport.java:175) at org.springframework.core.io。 support.PropertiesLoaderSupport.mergeProperties(PropertiesLoaderSupport.java:156) 在org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:80) ...... 20多個

回答

0

在src/main/resources /目錄中移動你的配置目錄,你的配置應該是

<context:property-placeholder location="classpath:config/redis.properties"/>