使用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>

图片说明

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

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

我找到问题了。主要是配置文件中没有扫描dao包,在spring-mybatis.xml里面注册一下dao就好了。

 <context:component-scan base-package="com.bruceliao.dao"/>