dlplaymaker 2017-04-17 13:14 采纳率: 0%
浏览 6353

使用SSM框架配置式开发(不用注解),为何Service中无法注入Dao?

我用Intellij Idea开发的,所以配置文件中出错会标识红色,spring-service.xml中的ref="IStudentDao"部分出错。
另外我用Maven做的项目管理,不知道是不是配置文件放置的路径有问题。附上我的项目目录结构:图片说明

部署到Tomcat上启动后,报No adapter for handler [com.bruceliao.controller.StudentController@12bc3bf8]: The DispatcherServlet configuration needs to include a HandlerAdapter that supports this handler

Mybatis配置文件:

    <configuration>
        <!--别名-->
        <typeAliases>
        <package name="com.bruceliao.beans"/>
        </typeAliases>
        <!--Mapper的位置-->
        <mappers>
        <package name="com.bruceliao.dao"/>
        </mappers>
    </configuration>

Spring配置文件:

spring-mybatis.xml

     <!--注册sqlSessionFactory-->
    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="configLocation" value="classpath:mybatis.xml"/>
        <property name="dataSource" ref="dataSource"/>
    </bean>
    <!--生成Dao代理对象-->
    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
        <property name="basePackage" value="com.bruceliao.dao"/>
    </bean>

spring-service.xml

    <!--注册Service-->
    <bean id="studentService" class="com.bruceliao.service.impl.StudentServiceImpl">
        <property name="studentDao" ref="IStudentDao"/>
    </bean>

spring-mvc.xml

    <bean id="/view/login.do" class="com.bruceliao.controller.StudentController">
        <property name="studentService" ref="studentService"/>
    </bean>

图片说明

  • 写回答

2条回答

  • bad_yixiong 2017-04-18 07:55
    关注

    部署到Tomcat上启动后,报No adapter for handler [com.bruceliao.controller.StudentController@12bc3bf8]: The DispatcherServlet configuration needs to include a HandlerAdapter that supports this handler

    这个应该是springmvc的问题吧 看看springmvc配置是否正确

    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog