How to inject String property in a spring bean

梦想与她 提交于 2020-01-03 04:51:23

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!