Java 按Weblogic中不工作的文件夹在Spring应用程序中加载多个属性文件

Java 按Weblogic中不工作的文件夹在Spring应用程序中加载多个属性文件,java,spring,spring-mvc,tomcat,weblogic-10.x,Java,Spring,Spring Mvc,Tomcat,Weblogic 10.x,我试图使用Spring PropertyPlaceHolder加载一组属性,它在Tomcat和Weblogic上都能正常工作。现在我将其更改为加载文件夹中的所有属性文件,它在Tomcat中运行良好,而在Weblogic上不工作 你能帮我找出哪里出了问题吗 下面是我在XML中更改的代码片段 <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <p

我试图使用Spring PropertyPlaceHolder加载一组属性,它在Tomcat和Weblogic上都能正常工作。现在我将其更改为加载文件夹中的所有属性文件,它在Tomcat中运行良好,而在Weblogic上不工作

你能帮我找出哪里出了问题吗

下面是我在XML中更改的代码片段

<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <value>file:${environment.config}*.properties
                </value>
            </list>
        </property>
        <property name="ignoreResourceNotFound" value="false" />
    </bean>
我还尝试添加org.springframework.beans.factory.config*
在weblogic.xml中,但没有帮助。

我使用applicationcontext.xml中的*.properties自定义了属性文件的加载。我扩展了“PropertiesFactoryBean”,初始化了该类,并从文件夹中读取所有属性,如下所示

public static List<Properties>  loadAllProperties() {
        File[] files = new File(System.getProperty("environment.config")).listFiles();
        List<Properties>  lstOfProperties = new ArrayList<>();
        if (files != null) {
            for (File file : files) {
                if (file.isFile()) {
                    String filename = file.getName();
                    String extension = filename.substring(filename.lastIndexOf(".") + 1, filename.length());

                    if (("properties").equals(extension)) {
                        Properties props = new Properties();
                        try {
                            props.load(new FileReader(file));
                        } catch (IOException e) {
                            LOGGER.error("Loading Properties " , e);
                        }
                         lstOfProperties.add(props);
                    }
                }
            }
        }
        return lstOfProperties;
    } 
公共静态列表loadAllProperties(){
File[]files=新文件(System.getProperty(“environment.config”)).listFiles();
List lstOfProperties=newarraylist();
如果(文件!=null){
用于(文件:文件){
if(file.isFile()){
字符串文件名=file.getName();
字符串扩展名=filename.substring(filename.lastIndexOf(“.”+1,filename.length());
如果((“属性”)等于(扩展)){
Properties props=新属性();
试一试{
加载(新文件阅读器(文件));
}捕获(IOE异常){
记录器错误(“加载属性”,e);
}
添加(道具);
}
}
}
}
归还财产;
} 
然后,我使用PropertiesFactoryBean的两个方法“setPropertiesArray”和“mergeProperties”,在加载时向系统添加了所有必需的属性


也可能有更好的选择,但这对我很有效,对其他人可能会有帮助。

属性文件位于类路径上或外部?外部,基本上在其他地方维护
public static List<Properties>  loadAllProperties() {
        File[] files = new File(System.getProperty("environment.config")).listFiles();
        List<Properties>  lstOfProperties = new ArrayList<>();
        if (files != null) {
            for (File file : files) {
                if (file.isFile()) {
                    String filename = file.getName();
                    String extension = filename.substring(filename.lastIndexOf(".") + 1, filename.length());

                    if (("properties").equals(extension)) {
                        Properties props = new Properties();
                        try {
                            props.load(new FileReader(file));
                        } catch (IOException e) {
                            LOGGER.error("Loading Properties " , e);
                        }
                         lstOfProperties.add(props);
                    }
                }
            }
        }
        return lstOfProperties;
    }