我有两个包含相同属性名称和引用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

最佳答案

我最终删除了所有:

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


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

08-07 03:02