Unsatisfied dependency expressed through field ‘baseMapper‘; nested exceptio

本文介绍了在使用Mybatis-Plus时遇到的报错原因及解决方法,重点是导入正确的依赖和使用@Mapper与@Service注解。确保在mapper接口上加上@Mapper注解,并在service接口实现类中加入@Service注解,以正确整合SpringBoot与Mybatis-Plus。

这个报错主要是在我是用mybatis-plus的时候遇到的,出现这个报错的原因主要有以下两点:

  1. 导入的依赖的问题:
    注意在使用spring boot整合mybatis-plus时导入的是如下依赖
        <dependency>
            <groupId>io.github.Caratacus</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
        <version>1.0.9</version>

而不是:

       <dependency>-->
            <groupId>com.suyeer</groupId>-->
            <artifactId>mybatis-plus</artifactId>-->
            <version>3.2.0.6</version>-->
        </dependency>-->
  1. 注解问题
    在mapper文件中的类中加入@Mapper注解
@Mapper
public interface UserMapper extends BaseMapper<Users> {
}

service接口实现类中加入@Service注解

@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, Users> implements UserService {
}
Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'rdWorkHourServiceImpl': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'psmPjtServiceImpl': Unsatisfied dependency expressed through field 'plnMilstnService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'plnMilStnServiceImpl': Unsatisfied dependency expressed through field 'psmPjtmilstnService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'psmPjtmilstnServiceImpl': Unsatisfied dependency expressed through field 'objectTypeService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'objectTypeServiceImpl': Unsatisfied dependency expressed through field 'lcTranService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'lcTranServiceImpl': Unsatisfied dependency expressed through field 'lclcPhaseService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'lcLcPhaseServiceImpl': Unsatisfied dependency expressed through field 'lcLcService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'lcLcServiceImpl': Unsatisfied dependency expressed through field 'wfWorkflowService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'wfWorkflowServiceImpl': Unsatisfied dependency expressed through field 'sysViewInfoService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sysViewInfoService': Unsatisfied dependency expressed through field 'wfFieldService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'wfFieldServiceImpl': Unsatisfied dependency expressed through field 'pageFieldService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'wfPageFieldServiceImpl': Unsatisfied dependency expressed through field 'wfPageService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'wfPageServiceImpl': Unsatisfied dependency expressed through field 'wfTabService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'wfTabServiceImpl': Unsatisfied dependency expressed through field 'nodeService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'wfNodeServiceImpl': Unsatisfied dependency expressed through field 'wfTransitionService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'wfTransitionServiceImpl': Unsatisfied dependency expressed through field 'viewComponent'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'viewComponentImpl': Unsatisfied dependency expressed through field 'valueConverComponent'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dyValueConverComponentImpl': Unsatisfied dependency expressed through field 'objOprefService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'objOprefServiceImpl': Unsatisfied dependency expressed through field 'actionHandler'; nested exceptio n is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'actionHandlerImpl': Unsatisfied dependency expressed through field 'entityExportComponent'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'entityExportComponentImpl': Unsatisfied dependency expressed through field 'versionsPlanComponent'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dyVersionsPlanComponentImpl': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'taskHandlerImpl': Bean with name 'taskHandlerImpl' has been injected into other beans [actionController,bizCommServiceImpl] in its raw version as part of a circular reference, but has eventually been wrapped. This means that said other beans do not use the final version of the bean. This is often the result of over-eager type matching - consider using 'getBeanNamesForType' with the 'allowEagerInit' flag turned off, for example.
最新发布
10-18
Write through caching 是一种缓存策略,其核心思想是将数据同时写入缓存和底层数据源。在这种策略下,应用程序与缓存进行交互,而缓存负责同步更新底层数据源。这种方式确保了缓存和数据源之间的一致性,但可能会增加写入操作的延迟,因为写入操作必须等待数据持久化到两个位置后才能完成[^2]。 ### 实现 Write Through 缓存策略 实现 Write Through 缓存策略的关键在于确保数据在缓存和持久化存储中同步更新。以下是实现该策略的典型步骤: 1. **拦截写入请求**:应用程序的写入请求首先发送到缓存层,而不是直接写入底层数据源。 2. **写入缓存**:缓存系统接收到写入请求后,将数据写入缓存。 3. **写入底层数据源**:在数据写入缓存后,缓存系统将数据同步写入底层数据源(如数据库、文件系统等)。 4. **确认写入完成**:只有当数据成功写入缓存和底层数据源后,系统才会向应用程序返回写入成功的响应。 ### 示例代码 以下是一个简单的 Python 示例,演示如何实现 Write Through 缓存策略。假设我们有一个简单的缓存系统和一个数据库: ```python class WriteThroughCache: def __init__(self, database): self.cache = {} self.database = database def write(self, key, value): # Step 1: Write to cache self.cache[key] = value # Step 2: Write to database (simulating synchronous write) self.database[key] = value print(f"Write through: {key} -> {value}") def read(self, key): # Check cache first if key in self.cache: print(f"Cache hit for {key}") return self.cache[key] # Fallback to database print(f"Cache miss for {key}, reading from database") return self.database.get(key, None) # Simulated database database = {} # Initialize cache with database cache = WriteThroughCache(database) # Example usage cache.write("user:1001", {"name": "Alice", "age": 30}) print(cache.read("user:1001")) # Output: {'name': 'Alice', 'age': 30} ``` 在这个示例中,`WriteThroughCache` 类模拟了一个简单的缓存系统,它将数据写入内存中的 `cache` 字典和一个模拟的 `database`。每次写入操作都会同步更新缓存和数据库。 ### 优缺点 **优点**: - **数据一致性**:由于数据同时写入缓存和底层数据源,因此缓存和数据源之间始终保持一致。 - **可靠性**:即使缓存失效或重启,数据仍然可以从底层数据源恢复。 **缺点**: - **性能开销**:每次写入操作都需要等待数据持久化到两个位置,增加了写入延迟。 - **复杂性**:需要处理缓存和数据源之间的同步逻辑,可能会增加系统的复杂性。 ### 适用场景 Write Through 缓存策略适用于对数据一致性要求较高的场景,例如金融交易系统、库存管理系统等。在这些场景中,数据的准确性和可靠性比性能更为重要。
评论 5
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值