gpt4 book ai didi

spring - 无法解析占位符

转载 作者:行者123 更新时间:2023-12-02 03:54:15 26 4
gpt4 key购买 nike

当我运行 junit 测试用例时,出现以下错误:

Invalid bean definition with name 'CacheRegionManagerFactory' defined in class path resource [com/bgc/ecm/core/caching/cacheRegionManager-ctx.xml]: Could not resolve placeholder 'appRoot'

org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'CacheRegionManagerFactory' defined in class path resource [com/bgc/ecm/core/caching/cacheRegionManager-ctx.xml]: Could not resolve placeholder 'appRoot'
at org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.processProperties(PropertyPlaceholderConfigurer.java:268)
at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:75)

cacheRegionManager-ctx.xml 文件:

<bean id="CacheRegionManagerFactory" class="com.bgc.ecm.core.caching.CacheRegionManagerFactory">
<property name="diskStoreCachePath" value="${diskStoreCacheRootPath}/${appRoot}/was/var/elnino/${appName}/${cloneNumber}"/>
<property name="defaultRegion" ref="DefaultRegion"/>
<property name="regionInfos" ref="CustomRegions"/>
</bean>

propertyContext.xml:

<context:property-placeholder 
location="classpath:/property/globalContext.properties,
classpath:/property/globalContext-${app.env}.properties,
classpath:/property/globalContext-${app.env}-${app.module}.properties,
classpath:/property/applicationContext.properties,
classpath:/property/applicationContext-${app.module}.properties,
classpath:/property/applicationContext-${app.env}.properties,
classpath:/property/applicationContext-${app.env}-${app.module}.properties"/>

并且applicationContext-DEV-FNT.properties包含:

appName=bgc-elnino-core-cluster
appRoot=ecm
cloneNumber=1
site=elnino-core

Junit 目标:

<target name="junit" depends="init-junit">
<copy todir="${TEST_BUILD_DIR}/" overwrite="true">
<fileset dir="${COMP_TESTCONFIG_DIR}">
<exclude name="*.properties.template" />
</fileset>
</copy>
<junit printsummary="on" fork="yes" forkmode="perBatch" haltonfailure="false" failureproperty="junit.failure" showoutput="false">
<classpath>
<path refid="CLASSPATH_JUNIT"/>
</classpath>
<batchtest fork="no" todir="${TEST_BUILD_DIR}">
<fileset dir="${COMP_TEST_SRC}" erroronmissingdir="false">
<include name="**/*Test.java" />
<include name="**/Test*.java" />
</fileset>
</batchtest>
<formatter type="xml" />
</junit>
<junitreport todir="${JUNIT_REPORT}">
<fileset dir="${TEST_BUILD_DIR}">
<include name="TEST-*.xml" />
</fileset>
<report format="frames" todir="${JUNIT_REPORT}"/>
</junitreport>
<delete dir="${TEST_BUILD_DIR}" />

</target>

env variable is:

public final void setupEnvironmentPropertiesIfNeeded()
{
String address = (new StringBuilder()).append("@").append(Integer.toHexString(System.identityHashCode(this))).toString();
if(StringUtils.isEmpty(System.getProperty("app.env")))
{
LOG.info((new StringBuilder()).append(address).append(" Environment property app.env will be set to DEV").toString());
System.setProperty("app.env", "DEV");
} else
{
LOG.info((new StringBuilder()).append(address).append(" Environment property app.env already set to:'").append(System.getProperty("app.env")).append("'").toString());
}
if(StringUtils.isEmpty(System.getProperty("app.module")))
{
LOG.info((new StringBuilder()).append(address).append(" Environment property app.module will be set to FNT").toString());
System.setProperty("app.module", "FNT");
} else
{
LOG.info((new StringBuilder()).append(address).append(" Environment property app.module already set to:'").append(System.getProperty("app.module")).append("'").toString());
}
}

最佳答案

您的属性文件似乎未加载。尝试使用显式加载属性文件:

<property file="applicationContext-DEV-FNT.properties" />

关于spring - 无法解析占位符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6490461/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com