已经有“控制器” bean方法

时间:2018-06-26 21:28:19

标签: java spring-mvc

我的dispatcher-servlet.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans.xsd
       http://www.springframework.org/schema/context
       http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">

    <context:component-scan base-package = "mvc"/>
    <bean class = "org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name = "prefix" value = "/WEB-INF/pages/" />
        <property name = "suffix" value = ".jsp" />
    </bean>

    <bean id = "dataSource" class = "org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name = "driverClassName" value = "oracle.jdbc.driver.OracleDriver" />
        <property name = "url" value = "jdbc:oracle:thin:@localhost:1521:XE" />
        <property name = "username" value = ""/>
        <property name = "password" value = ""/>
    </bean>

    <bean id = "jdbcTemplate" class = "org.springframework.jdbc.core.JdbcTemplate">
        <property name = "dataSource" ref = "dataSource"/>
    </bean>

    <bean id = "dao" class = "mvc.dao.DAOImpl">
        <property name = "template" ref = "jdbcTemplate"/>
    </bean>
</beans>

要使用REST,我需要<mvc:annotation-driven/>。但是将其添加到dispatcher-servlet.xml后,我得到的是“已经有'controllers'bean方法”。
控制器在这里http://collabedit.com/hfrv8
上课 这里的DAOimpl类http://collabedit.com/dms4s
完整的堆栈跟踪在这里http://collabedit.com/f7ux9
问题可能在哪里?

1 个答案:

答案 0 :(得分:0)

好吧,问题出在具有相同注释@RequestMapping(“ / viewAll1”)的Controllers类的几种方法中。评论完所有内容后,错误消失了