启动类位置不对,启动类应该在你的rvice和dao 的上一层,因为spring是从启动类所在目录的同级目录开始扫描的,当然你也可以放在其他地方,但需要配置,具体配置可以参考网上的其他文章!
mapper.xml文件的路劲配置是否正确,classpath指的是resources目录,如果不在resources目录下,注意正确配置路劲。
mapper接口类是否添加@repository注解,表示这是数据访问组件。如果采用注解的形式使用mybatis需要加@mapper
rvice层是否添加@rvice注解,将bean注入到上下文中.
启动类是否添加@mapperscan(扫描mapper),@entityscan(扫描实体类),如果启动类不在上面(1)所说的位置,则需要自己添加@comrepositor注解,自定义扫描的路径从中找出标识了需要装配的类自动装配到spring的bean容器中。
报错如下
2021-02-18 09:45:58,826 – starting bfshapplication on desktop-aapvn38 with pid 10552 (f:\ideaiu\work_place\bfsh\target\class started by aodexiusi in f:\ideaiu\work_place\bfsh)
2021-02-18 09:45:58,828 – running with spring boot v2.3.7.relea, spring v5.2.12.relea
2021-02-18 09:45:58,829 – no active profile t, falling back to default profiles: default
2021-02-18 09:45:58,868 – devtools property defaults active! t ‘spring.devtools.add-properties’ to ‘fal’ to disable
2021-02-18 09:45:58,868 – for additional web related logging consider tting the ‘logging.level.web’ property to ‘debug’
2021-02-18 09:45:59,438 – no mybatis mapper was found in ‘[com.wj.bfsh.mapper.*]’ package. plea check your configuration.
2021-02-18 09:45:59,809 – tomcat initialized with port(s): 8888 (http)
2021-02-18 09:45:59,816 – starting rvice [tomcat]
2021-02-18 09:45:59,816 – starting rvlet engine: [apache tomcat/9.0.41]
2021-02-18 09:45:59,925 – initializing spring embedded webapplicationcontext
2021-02-18 09:45:59,925 – root webapplicationcontext: initialization completed in 1057 ms
2021-02-18 09:45:59,969 – exception encountered during context initialization – cancelling refresh attempt: org.springframework.beans.factory.beancreationexception: error creating bean with name ‘sysurcontroller’: injection of resource dependencies failed; nested exception is org.springframework.beans.factory.beancreationexception: error creating bean with name ‘sysurrviceimpl’: injection of resource dependencies failed; nested exception is org.springframework.beans.factory.nosuchbeandefinitionexception: no qualifying bean of type ‘com.wj.bfsh.mapper.sysurmapper’ available: expected at least 1 bean which qualifies as autowire candidate. dependency annotations: {@javax.annotation.resource(shareable=true, lookup=, name=, description=, authenticationtype=container, type=class java.lang.object, mappedname=)}
2021-02-18 09:45:59,971 – stopping rvice [tomcat]
2021-02-18 09:45:59,978 – the web application [bfsh] appears to have started a thread named [abandoned connection cleanup thread] but has failed to stop it. this is very likely to create a memory leak. stack trace of thread:
java.lang.object.wait(native method)
java.lang.ref.referencequeue.remove(referencequeue.java:143)
com.mysql.jdbc.abandonedconnectioncleanupthread.run(abandonedconnectioncleanup过去分词作定语thread.java:40)
2021-02-18 09:45:59,986 –error starting applicationcontext. to display the conditions report re-run your application with ‘debug’ enabled.
2021-02-18 09:46:00,105 –***************************
application fai落榜生led to start
***************************description:
a component require艺校招生d a bean of type ‘com.wj.bfsh.mapper.sysurmapper’ that could not be found.
action:
consider defining a bean of type ‘com.wj.bfsh.mapper.sysurmapper’ in your configuration.
我的启动类:
@springbootapplication@mapperscan(bapackages = "com.wj.bfsh.mapper.*")public class bfshapplication { public static void main(string[] args) { springapplication.run(bfshapplication.class, args); }}
项目结构:
@mapperscan(bapackages = “com.wj.bfsh.mapper.*”)
修改为:
@mapperscan(bapackages = “com.wj.bfsh.mapper”)
其实就是dao层扫描的位置不对。
以上为个人经验,希望能给大家一个参考,也希望大家多多支持www.887551.com。
本文发布于:2023-04-04 15:51:39,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/fanwen/zuowen/05cb4eb9b0c74461bdefd77ee023100e.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文word下载地址:springboot+mybatis报错找不到实体类的问题.doc
本文 PDF 下载地址:springboot+mybatis报错找不到实体类的问题.pdf
留言与评论(共有 0 条评论) |