Java 方法调用FactoryBean';行不通

Java 方法调用FactoryBean';行不通,java,spring,ehcache,Java,Spring,Ehcache,我在类路径中创建了一个包含系统属性的属性文件,名称是system.properties 该文件类似于: system.project_name=springsilkworm 我还使用EHcache,即EHcache.xml,如: <diskStore path="${java.io.tmpdir}/${system.project_name}/cache" /> <context:property-placeholder location="classpath*:/syst

我在类路径中创建了一个包含系统属性的属性文件,名称是system.properties

该文件类似于:

system.project_name=springsilkworm
我还使用EHcache,即EHcache.xml,如:

<diskStore path="${java.io.tmpdir}/${system.project_name}/cache" />
<context:property-placeholder location="classpath*:/system.properties" ignore-resource-not-found="true" ignore-unresolvable="true" />

<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
        <property name="targetClass" value="java.lang.System" />
        <property name="targetMethod" value="setProperty" />
        <property name="arguments">
            <list>
                <value>system.project_name</value>
                <value>${system.project_name}</value>
            </list>
        </property>
    </bean>

<bean id="ehCacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
        <property name="configLocation" value="classpath:/ehcache.xml" />
        <property name="shared" value="true" />
    </bean>

我想使用system.properties中定义的system.project\u名称

我基于Spring开发了我的项目,因此我创建了applicationContext.xml,如下所示:

<diskStore path="${java.io.tmpdir}/${system.project_name}/cache" />
<context:property-placeholder location="classpath*:/system.properties" ignore-resource-not-found="true" ignore-unresolvable="true" />

<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
        <property name="targetClass" value="java.lang.System" />
        <property name="targetMethod" value="setProperty" />
        <property name="arguments">
            <list>
                <value>system.project_name</value>
                <value>${system.project_name}</value>
            </list>
        </property>
    </bean>

<bean id="ehCacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
        <property name="configLocation" value="classpath:/ehcache.xml" />
        <property name="shared" value="true" />
    </bean>

system.project\u名称
${system.project_name}
但当我启动我的应用程序时,我发现EHcahce使用的文件夹如下:


也就是说,MethodInvokingFactoryBean不起作用,我还使用System.getProperty(“System.project\u name”)代码在代码中获取属性,我得到了“null”的结果,为什么?我找不出错误。

可能是重复的是的,它们是相同的问题