spring-Kontext - how to load properties-Datei angegeben, die als " system-Eigenschaft in einer batch-Datei

Ich habe eine batch Datei die ein-system-Eigenschaft mit der config.Eigenschaften und Ausführung einer jar-Datei. Spring-context-Datei innerhalb der jar-Datei laden muss diese property-Datei, um die jdbc-Verbindung Einstellungen bean in der Kontext-Datei. Aber ich bekomme die Datei nicht gefunden " - Fehler, wie unten gezeigt. Jede Hilfe ist willkommen. Vielen Dank im Voraus.

org.springframework.beans.factory.BeanInitializationException: Could not load pr
operties; nested exception is java.io.FileNotFoundException: \${config.propertie
s.name} (The system cannot find the file specified)
org.springframework.beans.factory.BeanInitializationException: Could not load pr
operties; nested exception is java.io.FileNotFoundException: \${config.propertie
s.name} (The system cannot find the file specified)
        at org.springframework.beans.factory.config.PropertyResourceConfigurer.p
ostProcessBeanFactory(PropertyResourceConfigurer.java:78)
        at org.springframework.context.support.AbstractApplicationContext.invoke
BeanFactoryPostProcessors(AbstractApplicationContext.java:624)
        at org.springframework.context.support.AbstractApplicationContext.invoke
BeanFactoryPostProcessors(AbstractApplicationContext.java:599)
        at org.springframework.context.support.AbstractApplicationContext.refres
h(AbstractApplicationContext.java:398)
        at org.springframework.context.support.ClassPathXmlApplicationContext.<i
nit>(ClassPathXmlApplicationContext.java:139)
        at org.springframework.context.support.ClassPathXmlApplicationContext.<i
nit>(ClassPathXmlApplicationContext.java:83)
        at ax.bx.cx.ABCClass.main()
Caused by: java.io.FileNotFoundException: \${config.properties.name} (The system
 cannot find the file specified)
        at java.io.FileInputStream.open(Native Method)
        at java.io.FileInputStream.<init>(FileInputStream.java:106)
        at java.io.FileInputStream.<init>(FileInputStream.java:66)
        at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection
.java:70)
        at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLCon
nection.java:161)
        at org.springframework.core.io.UrlResource.getInputStream(UrlResource.ja
va:124)
        at org.springframework.core.io.support.PropertiesLoaderSupport.loadPrope
rties(PropertiesLoaderSupport.java:181)
        at org.springframework.core.io.support.PropertiesLoaderSupport.mergeProp
erties(PropertiesLoaderSupport.java:161)
        at org.springframework.beans.factory.config.PropertyResourceConfigurer.p
ostProcessBeanFactory(PropertyResourceConfigurer.java:69)

batch-Datei Inhalt:

set JAVA_OPTS=%JAVA_OPTS% -Dconfig.properties.name=../config.properties
java -classpath .;../lib/xyz.jar ax.bx.cx.ABCClass

Frühjahr Kontext-Datei innerhalb der jar:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xsi:schemaLocation="
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd">

<context:property-placeholder location="classpath:${config.properties.name}"/>

<!-- other beans declared below -->

</beans>
  • Suche ein ähnliches problem, ich fand diese Ressource, die gibt einen schönen überblick über das verwalten von Eigenschaften mit Feder. summa-tech.com/blog/2009/04/20/...
InformationsquelleAutor joerobles | 2011-03-25
Schreibe einen Kommentar