【发布时间】:2019-03-28 06:07:50
【问题描述】:
很抱歉复制了这个article。我想评论它,但没有 50 分的声誉我无法评论,所以......
我有
private boolean stopLoggingIntoDb;
....
public void setStopLoggingIntoDb(String stopLoggingIntoDb) {
this.stopLoggingIntoDb = BooleanUtils.toBoolean(stopLoggingIntoDb.replaceAll("[^A-Za-z]", ""));
logger.warn("Logging into SiebelMethodLogs is " + (!this.stopLoggingIntoDb ? "ON" : "OFF"));
}
和 XML
<bean id="siebelMethodProcessor" class="com.entities.utils.Logger">
<property name="logService" ref="logService"/>
<property name="stopLoggingIntoDb" value="${monitor.siebel.stopLogging}"/>
</bean>
在这种情况下,一切正常,但是如果我将 setter 方法中的属性从 stopLoggingIntoDb 更改为 stopLog 并将 XML 中的属性名称也更改为 stopLog,Spring 说我无效属性“stopLoggingIntoDb”或 Bean 属性“stopLog” ' 不可写。
因此,我的问题是 Spring 对 setter 方法做了什么?注入哪个值,在获取注入时搜索哪个字段/属性?
【问题讨论】:
-
你能把修改后的代码也贴出来吗?