我有一个用于正在编写的 LDAP 应用程序的 beans.xml 文件。我允许用户选择几个 LdapContextSource(s)。对于每一个我都有一个不同的豆子,例如
<bean id="ldapTemplate" class="yyy.LdapTemplate">
<constructor-arg ref="contextSource1" />
</bean>
<bean id="contextSource1" class="xxx.LdapContextSource">
...
</bean>
<bean id="contextSource2" class="xxx.LdapContextSource">
...
</bean>
<bean id="contextSource3" class="xxx.LdapContextSource">
...
</bean>
您可以看到这些上下文源 bean 中只有一个被实例化,因为 ldapTemplate bean 只引用了一个。但是,当我运行我的应用程序时,stdout 中的 Spring 日志消息会提供有关每个上下文源的信息,即使只有一个依赖。
2011 年 1 月 25 日上午 11:56:36 org.springframework.ldap.core.support.AbstractContextSource afterPropertiesSet 信息:未设置属性“userDn”-匿名上下文将用于读写操作 2011 年 1 月 25 日 11:56:37 AM org.springframework.ldap.core.support.AbstractContextSource afterPropertiesSet INFO:未设置属性“userDn”-匿名上下文将用于读写操作 2011 年 1 月 25 日上午 11:56:37 org.springframework.ldap.core。 support.AbstractContextSource afterPropertiesSet INFO: Property 'userDn' not set - 匿名上下文将用于读写操作
我的问题是:
(1) Spring 对未引用/不依赖的上下文源做了什么?它们永远不应该在我的应用程序中实例化,我担心 Spring 正在为这些 bean 中的每一个提供日志信息。
(2) 我应该注释掉应用程序中没有使用的上下文源bean吗?不评论它们会有什么后果?标准做法是什么?
谢谢,
ktm