Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I am getting
**Caused by: org.springframework.beans.TypeMismatchException: Failed to convert value of type 'java.lang.String' to required type 'java.lang.Boolean'; nested exception is java.lang.IllegalArgumentException: **
I believe this happens due to missing spring place holder config. But I have the bean initialised in application context and still getting this error. Can any one help me out??
@Value("${com.test.isTestEnable")
public Boolean isTestEnable;
Spring Properties Class
public class SpringPropertiesUtil extends PropertyPlaceholderConfigurer {
private static HashMap<String, String> systemPropertiesMap;
private int springSystemPropertiesMode = SYSTEM_PROPERTIES_MODE_FALLBACK;
public static String getProperty(final String name) {
return systemPropertiesMap.get(name);
@Override
protected void processProperties(final ConfigurableListableBeanFactory beanFactory, final Properties props) throws BeansException {
super.processProperties(beanFactory, props);
systemPropertiesMap = new HashMap<String, String>();
for (final Object key : props.keySet()) {
final String keyStr = key.toString();
final String valueStr = resolvePlaceholder(keyStr, props, springSystemPropertiesMode);
systemPropertiesMap.put(keyStr, valueStr);
@Override
public void setSystemPropertiesMode(final int systemPropertiesMode) {
super.setSystemPropertiesMode(systemPropertiesMode);
springSystemPropertiesMode = systemPropertiesMode;
my application-context file
<bean id="placeholderConfig" class="com.test.SpringPropertiesUtil">
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
<property name="locations">
<value>file:${config.path}/application.properties</value>
<value>file:${config.path}/log.properties</value>
</list>
</property>
</bean>
Your real issue was just a typo at @Value("${com.test.isTestEnable") - you're missing a closing curly bracket } at the end of the expression
This should work completely fine:
@Value("${com.test.isTestEnable}")
public Boolean isTestEnable;
–
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.