Spring-单例问题-没有名为';的bean';建立

Spring-单例问题-没有名为';的bean';建立,spring,singleton,Spring,Singleton,嘿,我不知道这个bean定义有什么问题。我得到了这个错误。特别是第14条日志消息很有趣。这是我的应用程序上下文文件 httpParams是在httpParamBean中设置的单例,然后由TscManager和httpClient使用。各种依赖于设置是我努力解决的结果。您不能使用“#{httpParams}”引用其他bean 将构造函数替换为以下内容: <constructor-arg ref="httpParams" /> 明白了,它必须是这样的:“” 谢谢大家Spring日

嘿,我不知道这个bean定义有什么问题。我得到了这个错误。特别是第14条日志消息很有趣。这是我的应用程序上下文文件


httpParams是在httpParamBean中设置的单例,然后由TscManager和httpClient使用。各种依赖于设置是我努力解决的结果。

您不能使用
“#{httpParams}”
引用其他bean

将构造函数替换为以下内容:

<constructor-arg ref="httpParams" />

明白了,它必须是这样的:“




谢谢大家

Spring日志并没有说明在调试模式下应用程序上下文初始化失败的原因。。。上次你能看一下吗?你需要依赖属性吗?我从来都不需要这个;Spring通常在默认情况下非常擅长管理这些东西。我认为你可能导致了循环依赖。没有循环依赖也是一样的结果…顺便说一句,它是这样开始的:ApplicationContext ctx=new ClassPathXmlApplicationContext(“app context.xml”);调试(“ApplicationContext就绪”);ThreadManager-ThreadManager=(ThreadManager)ctx.getBean(“ThreadManager”);日志以MethodInvokingFactoryBean结尾,我需要它调用schemeReg上的register方法,参数值为scheme Bean。我认为您可能需要创建一个工厂/代理类,并在SpringXML中使用它。MethodInvokingFactoryBean需要一个类——您将给它一个schemeReg作为bean。我还没有看过代码,但是有什么帮助吗?此外,您可以将方案所需的SocketFactory创建为一个bean,而不是使用Spring EL—请参阅Spring文档中的init method属性。
<bean id="plainSocketFactory" class="org.apache.http.conn.scheme.PlainSocketFactory"
      factory-method="getSocketFactory"/>

<bean id="scheme" class="org.apache.http.conn.scheme.Scheme">
    <constructor-arg value="http"/>
    <constructor-arg ref="plainSocketFactory"/>
    <constructor-arg type="int" value="80" />
</bean>

<bean id="schemeReg" class="org.apache.http.conn.scheme.SchemeRegistry"/>

<bean id="configurator" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
    <property name="targetObject"><ref local="schemeReg"/></property>
    <property name="targetMethod" value="register"/>
    <property name="arguments">
        <list>
            <ref bean="scheme"/>
        </list>
    </property>
</bean>