开发者

How to inject String property in a spring bean

开发者 https://www.devze.com 2023-03-18 04:28 出处:网络
We inject simple property with configuration as shown below : <bean id=\"myService\" class=\"com.aaa.bbb.ccc.MyServiceImpl\">

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 annotat开发者_运维知识库ions?


Using the @Value annotation. It supports SpEL as well, which means you can load a properties file and have @Value("${someConfigurationProperty}")

0

精彩评论

暂无评论...
验证码 换一张
取 消