I have a config.properties file:
limit=10
My springmvc-servlet.xml:
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:config/config.properties</value>
</list>
</property>
</bean>
This is my controller class:
@Controller
@RequestMapping(...)
public class Test extends BaseController
{
@Value("${limit}") Integer limit; // This doesn't work
@Value("#{T(java.lang.Integer).parseInt(${limit})}") Integer limit; // This also doesn't work
@RequestMapping(...)
@ResponseBody
public String session()
{
return String.valueOf(limit);
}
}
error message is:
Error creating bean with name 'test': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: java.lang.Integer **.Test.limit; nested exception is org.springframework.beans.factory.BeanExpressionException: Expression parsing failed; nested exception is org.springframework.expression.spel.SpelParseException: EL1043E:(pos 31): Unexpected token. Expected 'rparen())' but was 'lcurly({)'
any ideas?