java - 已经有 'controllers' bean方法

标签 java spring-mvc

我的调度程序-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后,我得到“已经有' Controller 'bean方法”。
Controller 类在这里 http://collabedit.com/hfrv8
DAOimpl 类在这里 http://collabedit.com/dms4s
完整的堆栈跟踪在这里 http://collabedit.com/f7ux9
问题可能出在哪里?

最佳答案

嗯,问题出在具有相同注释 @RequestMapping("/viewAll1") 的 Controllers 类的多个方法中。评论完所有内容后,错误消失了

关于java - 已经有 'controllers' bean方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51051600/

相关文章:

c# - RAD 编程语言编写一个 windows 应用程序来显示文本、播放音频文件和显示弹出气球

java - 在 Play Framework 中创建自定义的 404/500 错误页面

java - 程序期间重置全局字符数组的值

java - 使用 final 参数是否会阻止类成为线程安全的?

java - 当我使用 java -jar File.jar 运行 spring-boot 时,没有 ServletContext 资源 [/WEB-INF/layouts/layouts.xml] 的 URL

Java Google Plus 通过 oAuth 2.0 访问

java - 用户双击按钮后在数据库中双重插入

java - 无法从 Base64 身份验证、spring security 获取登录名和密码

java - 应用程序无法使用类路径启动.../负匹配

java - Servlet异常: No adapter for handler just for one service