Trying to auto-wire properties to a bean in Spring 3.0.5.RELEASE, I'm using:
config.properties
:username=myusername
main-components.xml
:<context:property-placeholder location="classpath:config.properties" />
MyClass:
@Service public class MyClass { @Value("${username}") private String username; ... }
As a result, username gets set to literally "${username}"
, so the expression doesn't get parsed. My other auto-wired dependencies on this class get set, and Spring doesn't throw any exception. I also tried to add @Autowired
but it didn't help.
If I parse properties to a separate bean and then use @Autowired
+ @Qualifier
, it works:
<bean id="username" class="java.lang.String">
<constructor-arg value="${username}"/>
</bean>
Any ideas how to use just @Value
? Maybe I need to include some Spring dependency that I haven't? Thank you