控制器spring bean共享属性和引用bean导致javax.servlet.UnavailableException

时间:2014-05-05 20:59:01

标签: java spring

我有两个包含相同属性名和引用bean的bean,这可能导致我的错误吗?:

javax.servlet.UnavailableException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping#0': Initialization of bean failed; nested exception is java.lang.IllegalStateException: Cannot map handler x to URL path /path There is already handler of type [class myclass] mapped.

代码:

<bean name="bean1"
    class="myclass1">
    <property name="property">
        <ref bean="ref" />
    </property>
</bean>



<bean name="bean2"
    class="myclass2">
    <property name="property">
        <ref bean="ref" />
    </property>
</bean>

我似乎无法在其他任何地方追踪我的错误。如果您需要更多信息,请发表评论。

编辑:控制台打印错误为Caused by: java.lang.IllegalStateException: Cannot map handler

我还有另一个例外:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping#0': Initialization of bean failed

1 个答案:

答案 0 :(得分:1)

我最终删除了所有内容:

<bean name="bean2"
    class="myclass2">
    <property name="property">
        <ref bean="ref" />
    </property>
</bean>

我的控制器开始正确映射。