问题
We inject simple property with configuration as shown below :
<bean id="myService" class="com.aaa.bbb.ccc.MyServiceImpl">
<property name="myProp" value=""/>
</bean>
How would you do it with annotations?
回答1:
Using the @Value
annotation. It supports SpEL as well, which means you can load a properties file and have @Value("${someConfigurationProperty}")
来源:https://stackoverflow.com/questions/6630965/how-to-inject-string-property-in-a-spring-bean