首页 新闻 会员 周边 捐助

控制台报错找不到bean

0
[待解决问题]

一个简单跟着网上打的后端程序,控制台报错Spring无法找到UserMapper的Bean定义,导致userServiceImpl无法注入baseMapper。2025-04-08T16:20:29.450+08:00 ERROR 25760 --- [ main] o.s.boot.SpringApplication : Application run failed

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'controller': Unsatisfied dependency expressed through field 'userService': Error creating bean with name 'userServiceImpl': Unsatisfied dependency expressed through field 'baseMapper': No qualifying bean of type 'com.example.wms.mapper.UserMapper' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}








项目结构为
.gitattributes
│ .gitignore
│ HELP.md
│ mvnw
│ mvnw.cmd
│ pom.xml

├─.mvn
│ └─wrapper
│ maven-wrapper.properties

├─src
│ ├─main
│ │ ├─java
│ │ │ └─com
│ │ │ └─example
│ │ │ └─wms
│ │ │ │ WmsApplication.java
│ │ │ │
│ │ │ ├─controller
│ │ │ │ Controller.java
│ │ │ │
│ │ │ ├─entity
│ │ │ │ User.java
│ │ │ │
│ │ │ ├─mapper
│ │ │ │ UserMapper.java
│ │ │ │
│ │ │ └─service
│ │ │ │ UserService.java
│ │ │ │
│ │ │ └─impl
│ │ │ UserServiceImpl.java
│ │ │
│ │ └─resources
│ │ │ application.yml
│ │ │
│ │ ├─static
│ │ └─templates
│ └─test
│ └─java
│ └─com
│ └─example
│ └─wms
│ WmsApplicationTests.java

└─target
├─classes
│ │ application.yml
│ │
│ └─com
│ └─example
│ └─wms
│ │ WmsApplication.class
│ │
│ ├─controller
│ │ Controller.class
│ │
│ ├─entity
│ │ User.class
│ │
│ ├─mapper
│ │ UserMapper.class
│ │
│ └─service
│ │ UserService.class
│ │
│ └─impl
│ UserServiceImpl.class

└─generated-sources
└─annotations
不知道错在哪里,更着网上各种教程越改越乱。一个简单的程序出的错应该不是很大。问问有经验的人具体错哪了。

Jacksoner的主页 Jacksoner | 初学一级 | 园豆:14
提问于:2025-04-08 16:36
< > 豆包AI编程
分享
所有回答(2)
0

mp依赖错了,添加的支持不了spring3

Jacksoner | 园豆:14 (初学一级) | 2025-04-08 16:57
0

WmsApplication 类加一下 @MapperScan("com.example.wms.mapper") 试试

withzZ | 园豆:202 (菜鸟二级) | 2025-04-08 21:08

已经解决了,是由于mp3.4和spring boot3不兼容,换成3.5就行了

支持(0) 反对(0) Jacksoner | 园豆:14 (初学一级) | 2025-04-08 21:10
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册
Top