For primitives, you can use the @Value annotation. A common scenario is to have a PropertyPlaceholderConfigurer that has loaded values from a properties file and then has @Value("${property.key}")
You can also define your values as beans, which is an older school:
<bean id="foo" class="java.lang.Integer" factory-method="valueOf"> <constructor-arg value="20" /> </bean>
and then
@Autowired @Qualifier("foo") private int foo;
source share