Java 带有自定义类加载器的PropertyPlaceHolderConfigure

Java 带有自定义类加载器的PropertyPlaceHolderConfigure,java,spring,Java,Spring,我正在尝试编写一个框架,可以动态加载插件。加载过程中的一个步骤是加载属性文件“properties.plugin”。我想将其加载到PropertyPlaceHolderConfigure中,但是它使用的类加载器似乎与GenericApplicationContext设置使用的类加载器不同 我创建上下文的代码: GenericApplicationContext ctx = new GenericApplicationContext(); if(classLoader !=null)

我正在尝试编写一个框架,可以动态加载插件。加载过程中的一个步骤是加载属性文件“properties.plugin”。我想将其加载到PropertyPlaceHolderConfigure中,但是它使用的类加载器似乎与GenericApplicationContext设置使用的类加载器不同

我创建上下文的代码:

GenericApplicationContext ctx = new GenericApplicationContext();
    if(classLoader !=null)
        ctx.setClassLoader(classLoader);
    ctx.getDefaultListableBeanFactory().setAllowBeanDefinitionOverriding(false);

    XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(ctx);
    xmlReader.setBeanClassLoader(classLoader);
    int totalBeanCount = 0;
    List<Resource> processedResources = new ArrayList<Resource>(resources.length);
    for(Resource r:resources)
    {
        try
        {
            int loadedBeanCount = xmlReader.loadBeanDefinitions(r);
            totalBeanCount += loadedBeanCount;
            processedResources.add(r);

        }
        catch(BeanDefinitionStoreException e)
        {

            throw e;
        }
    }
如果我在上下文上设置类加载器之前添加它,那么它就可以工作

我也尝试过classpath:properties/properties.plugin,properties.plugin,classpath*:properties.plugin

是否该PropertyPlaceHolderConfigure使用的类加载器与在ctx上设置的类加载器不同?如果是,是否有方法设置它使用的类加载器

我没有看到setClassLoader方法

 Thread.currentThread().setContextClassLoader(classLoader);
似乎使它能够工作,所以它必须使用这个类加载器,而不是上下文中设置的类加载器

classLoader.getResource("properties/properties.plugin");
 Thread.currentThread().setContextClassLoader(classLoader);