1. 问题描述
在启动Junit跑单测加载资源配置文件的时候遇到以下异常信息:
Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'activity_template_id' in string value "${activity_template_id}" at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:173) at org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:125) at org.springframework.beans.factory.config.PropertyPlaceholderConfigurer$PlaceholderResolvingStringValueResolver.resolveStringValue(PropertyPlaceholderConfigurer.java:258) at org.springframework.beans.factory.config.BeanDefinitionVisitor.resolveStringValue(BeanDefinitionVisitor.java:282) at org.springframework.beans.factory.config.BeanDefinitionVisitor.resolveValue(BeanDefinitionVisitor.java:204) at org.springframework.beans.factory.config.BeanDefinitionVisitor.visitPropertyValues(BeanDefinitionVisitor.java:141) at org.springframework.beans.factory.config.BeanDefinitionVisitor.visitBeanDefinition(BeanDefinitionVisitor.java:82) at org.springframework.beans.factory.config.PlaceholderConfigurerSupport.doProcessProperties(PlaceholderConfigurerSupport.java:206) ... 29 more
2. 问题分析
在读取配置问题信息的时候使用了入下方法:
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" depends-on="genernatePropertyFile"> <property name="location"> <value>file:D:/idev/antx.properties</value> </property> </bean>
那么出现异常信息的可能性有三种
(1)location中的属性文件配置错误
(2)location中定义的配置文件里面没有对应的placeholder值
(3)第三种就比较麻烦点,可能是Spring容器的配置问题
Spring容器采用反射扫描的发现机制,在探测到Spring容器中有一个org.springframework.beans.factory.config.PropertyPlaceholderConfigurer的Bean就会停止对剩余PropertyPlaceholderConfigurer的扫描(Spring 3.1已经使用PropertySourcesPlaceholderConfigurer替代PropertyPlaceholderConfigurer了)。
而<context:property-placeholder/>这个基于命名空间的配置,其实内部就是创建一个PropertyPlaceholderConfigurer Bean而已。换句话说,即Spring容器仅允许最多定义一个PropertyPlaceholderConfigurer(或<context:property-placeholder/>),其余的会被Spring忽略掉(其实Spring如果提供一个警告就好了)。
3.解决方案
(1)
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" depends-on="genernatePropertyFile"> <property name="location"> <value>file:D:/idev/antx.properties</value> </property> <property name="ignoreUnresolvablePlaceholders" value="true </bean>
(2)
<context:property-placeholder location="classpath*:redis.properties" ignore-unresolvable="true" />
相关推荐
按官方配置好了 developer.... Could not resolve com.huawei.agconnect 解决方法:把相应的插件用本地化安装 agconnect-crash-symbol-lib-1.6.1.300.jar agconnect-apms-plugin-1.6.1.300.jar agcp-1.6.1.300.jar。
myeclipse创建maven工程报错 Could not resolve
Caused by: org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all artifacts for configuration ‘:classpath’. 提示错误:Read Time out ...
hive 开发UDF 使用maven工程 引发jar包缺失 hive 开发UDF 使用maven工程 引发jar包缺失
Android Studio更新3.6.3之后出现Could not resolve all artifacts for configuration ‘:classpath’.问题你是否和我一样,只因在人群中多看了他一眼?![在这里插入图片描述]...
Resolve Weblogic Hang _ Core
$_SERVER,$_HTTP,__FILE__
[INFO] ———————————————————————— [INFO] Reactor Summary for demo 0.0.1-SNAPSHOT: [INFO] [INFO] demo ……………………………………….. FAILURE [18:18 min] [INFO] admin-service ...
主要介绍了解决Unable to access 'https://gitee.com/自己的项目/': Could not resolve host: gitee.com问题,需要的朋友可以参考下
Could not resolve all dependencies for configuration ‘:classpath’. Could not resolve com.android.tools.build:gradle:2.1.2. ………. 等6个error 上网百度csdn,结果试下各种方法,依旧没用。 搞了一天,...
1.vue项目中config文件下index.... assetsRoot: path.resolve(__dirname, '../yiTownWebApp'), assetsSubDirectory: 'static', assetsPublicPath: '/yiTownWebApp/',//这个地方使用绝对路径很重要 /** * Source Map
qt.network.ssl: QSslSocket: cannot resolve TLSv1_1_client_method qt.network.ssl: QSslSocket: cannot resolve TLSv1_2_client_method qt.network.ssl: QSslSocket: cannot resolve TLSv1_1_server_method qt....
linux fs nfs dns resolve.c.
新建maven项目时报Could not resolve archetype org.apache.maven.archetypes
Error:Could not resolve all files for configuration ‘:app:debugCompileClasspath’. > Could not resolve com.android.support:appcompat-v7:26.0.0-beta1. Required by: project :app > Could not ...
Forward and reverse resolving names under Unix. The program provides direct and inverse resolving names under Unix....$./resolve 127.0.0.1 localhost $./resolve.exe caxapa.ru caxapa.ru: 90.156.150.226.
Contains the CIFS DFS upcall routines used for hostname to IP address translation for Linux v2.13.6.
Contains the CIFS DFS upcall routines used for hostname to IP address translation.
达芬奇官网的测试版,大小限制分7个分卷上传。音视频剪辑软件,比Pr好多很多。
Microsoft OLE DB Provider for ODBC Drivers 错误'80040e4d'[Oracle][ODBC][Ora]ORA-12154: TNS:could not resolve the connect identifier specified. 使用PL-SQL Developer能连接上Oracle,但是ASP+ODBC连不上...