2014-11-17 3 views
0

클래스 경로에 appcontext.xml 파일이 있습니다. appcontext.xml의 config.properties 파일을 사용하여 데이터베이스 속성을 읽습니다. .xml 파일의 .properties 파일 읽기

org.springframework.beans.factory.BeanInitializationException: Could not load properties; nested exception is java.io.FileNotFoundException: class path resource [C:/prov-eng-2/prov-eng/provfwk/pf-core/src/main/config/core/config.properties] cannot be opened because it does not exist 
    at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:89) ~[spring-beans-4.0.3.RELEASE.jar:4.0.3.RELEASE] 
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:265) ~[spring-context-4.0.3.RELEASE.jar:4.0.3.RELEASE] 
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:162) ~[spring-context-4.0.3.RELEASE.jar:4.0.3.RELEASE] 
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:609) ~[spring-context-4.0.3.RELEASE.jar:4.0.3.RELEASE] 
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464) ~[spring-context-4.0.3.RELEASE.jar:4.0.3.RELEASE] 
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139) ~[spring-context-4.0.3.RELEASE.jar:4.0.3.RELEASE] 
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83) ~[spring-context-4.0.3.RELEASE.jar:4.0.3.RELEASE] 
    at com.gsl.pf.core.AdaptorManager.<init>(AdaptorManager.java:28) ~[pf-core-0.1.0-SNAPSHOT.jar:na] 
    at com.gsl.pf.core.AdaptorManager.getInstance(AdaptorManager.java:34) ~[pf-core-0.1.0-SNAPSHOT.jar:na] 
    at com.gsl.pf.fwk.FrameworkLoader.initialize(FrameworkLoader.java:35) ~[pf-fwk-0.1.0-SNAPSHOT.jar:na] 
    at com.gsl.pf.scimsvr.app.Loader.initialize(Loader.java:32) ~[classes/:na] 
    at com.gsl.pf.scimsvr.app.ScimServer.start(ScimServer.java:62) [classes/:na] 
    at com.gsl.pf.scimsvr.app.ScimServer.main(ScimServer.java:47) [classes/:na] 
Caused by: java.io.FileNotFoundException: class path resource [C:/prov-eng-2/prov-eng/provfwk/pf-core/src/main/config/core/config.properties] cannot be opened because it does not exist 
    at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:158) ~[spring-core-4.0.3.RELEASE.jar:4.0.3.RELEASE] 
    at org.springframework.core.io.support.EncodedResource.getInputStream(EncodedResource.java:143) ~[spring-core-4.0.3.RELEASE.jar:4.0.3.RELEASE] 
    at org.springframework.core.io.support.PropertiesLoaderUtils.fillProperties(PropertiesLoaderUtils.java:98) ~[spring-core-4.0.3.RELEASE.jar:4.0.3.RELEASE] 
    at org.springframework.core.io.support.PropertiesLoaderSupport.loadProperties(PropertiesLoaderSupport.java:175) ~[spring-core-4.0.3.RELEASE.jar:4.0.3.RELEASE] 
    at org.springframework.core.io.support.PropertiesLoaderSupport.mergeProperties(PropertiesLoaderSupport.java:156) ~[spring-core-4.0.3.RELEASE.jar:4.0.3.RELEASE] 
    at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:80) ~[spring-beans-4.0.3.RELEASE.jar:4.0.3.RELEASE] 
    ... 12 common frames omitted 

는 다른 존재, 속성 파일은 SRC/메인/설정/코어/config.properties 구조에 저장되고 나는, 같은 XML 파일에
<property name="locations"> 
    <list> 
     <value>${PF_CORE_HOME}/config/core/config.properties</value> 
    </list> 
</property> 

그것을 사용하고 있지만 오류 제공 .xml의 .property 파일을 읽는 방법.

+0

속성을로드 할 수 없습니다. 중첩 예외는 java.io.FileNotFoundException : 클래스 경로 리소스 [C : /prov-eng-2/prov-eng/provfwk/pf-core/src/main/config/core/config.properties]가 열리지 않기 때문에 존재하지 않음 – Maksym

+0

예외를 읽었습니까? – Maksym

+0

' classpath : /core/config.properties'클래스 경로에 파일을 복사하면. –

답변

0

이렇게하면 제대로 작동합니다.

여기에 문제의 :

Caused by: java.io.FileNotFoundException: class path resource [C:/prov-eng-2/prov-eng/provfwk/pf-core/src/main/config/core/config.properties] cannot be opened because it does not exist 

당신은 CLASSPATH에서이 파일을 읽고,하지만 그 경로는 그것의 일부가 아닙니다.

CLASSPATH에/src를 포함하지 마십시오. 해당 .properties 파일을/resources 디렉토리에 넣고 CLASSPATH에 패키지 (예 :/classes 아래의 상대 경로)를 넣습니다.