spring注入dao包,提示找不到dao包下的方法

Servlet.service() for servlet [dispatcherServlet] in context with path [/Textprj_war_exploded] threw exception [Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.hjy.dao.UserinfoDao.findByUsername] with root cause
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.hjy.dao.UserinfoDao.findByUsername

1、mybatis配置的dao接口和xml映射路径是否正确?

2、mapper.xml的命名空间(namespace)是否跟dao接口的包名一致?

3、接口的方法名,与xml中的一条sql标签的id一致

4、看看你的target文件夹下是否把xml的文件打包进去?如果没有需要配置一下

<resources>    
    <resource>    
        <directory>src/main/java</directory>    
        <includes>    
            <include>**/*.xml</include>    
        </includes>    
        <filtering>true</filtering>    
    </resource>    
</resources>    

这个问题还是比较好排查的,如果方法名映射没问题很可能是配置的路径没对。比如classpath:.......指定的xml文件是否正确

看看xml中是否有跟方法名对应的id的sql