如何將屬性值注入使用注釋配置的Spring Bean?我有一堆Spring bean,它們是通過注釋從類路徑中獲取的,例如@Repository("personDao")public class PersonDaoImpl extends AbstractDaoImpl implements PersonDao {
// Implementation omitted}在Spring XML文件中,定義了一個PropertyPlaceholderConfigurer:<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="/WEB-INF/app.properties" /></bean>我想將app.properites中的一個屬性注入上面顯示的bean中。我不能簡單地做一些事情<bean class="com.example.PersonDaoImpl">
<property name="maxResults" value="${results.max}"/></bean>因為PersonDaoImpl在Spring XML文件中沒有特征(它是通過注釋從類路徑中獲取的)。我有以下幾點:@Repository("personDao")public class PersonDaoImpl extends AbstractDaoImpl implements PersonDao {
@Resource(name = "propertyConfigurer")
protected void setProperties(PropertyPlaceholderConfigurer ppc) {
// Now how do I access results.max?
}}但是我不清楚我如何訪問我感興趣的房產(chǎn)ppc?
添加回答
舉報
0/150
提交
取消