2012-05-03 6 views
3

내 OSGi 번들에 config.properties이 있습니다. 그러나 OSGi 번들은 그것을 읽을 수 없다. 내가 뭔가은 OSGi처럼 보인다 config.propertiesOSGi 번들 읽기 구성 등록 정보

<bean id="propertyConfigurer" 
    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> 
    <property name="location" value="config.properties" /> 
</bean> 

을 읽어 봄 사용하고

Application context refresh failed (OsgiBundleXmlApplicationContext(bundle=dao, config=osgibundle:/META-INF/spring/*.xml)) 
org.springframework.beans.factory.BeanInitializationException: Could not load properties; nested exception is java.io.FileNotFoundException 

.xml 파일을 읽습니다. 누군가가 어떤 생각을 가지고 있습니까?

+2

config.properties 파일을 찾을 수 없습니다. 번들에 어디에 있습니까? – FrVaBe

+0

META-INF 폴더에 넣었습니다. 그리고 나는 config 파일을 번들 외부에 두는 방법과 전역 설정과 같은 동작을 찾고 싶다. 가능합니까? – snow8261

답변

2

값 속성에 올바른 리소스를 지정해야합니다.

  • ClassPathResource가 : value="classpath:/META-INF/config.properties"
  • FileSystemResource : value="file:C:/foobar/config.properties"

당신이 시스템 등록 정보를 사용할 수있는 라이브러리 외부 파일 (예를 -DpropertyFile=C:/loremIpsum/config.properties) 배치 할 경우에 처럼, 일부 built in implementations 있습니다 경로를 지정하십시오 (예 :

).
value="file:${propertyFile}" 

(스프링 3 이후) 0.? 심지어 기본 값으로

value="file:${propertyFile:C:/foobar/config.properties}" 

(가 시스템 속성입니다. 나는 또한 ClassPathResource가 잘 작동하는지 모르겠습니다을 설정하는 방법에 대한 귀하의 OSGi 프레임 워크에서보세요/OSGi 프레임 환경에서 권장합니다.)

+0

위대한! 고마워, 나는 그것을 시도 할 것이다. – snow8261

+0

맞아, 고마워. – snow8261