2017-02-14 74 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"/>