You've already forked FrameTour-BE
refactor(core): 添加 Lazy 注解解决循环依赖问题
- 在多个 Service 类中为注入的依赖添加 @Lazy 注解 - 修改了微信支付服务实现类中的依赖注入方式 - 更新了打印机服务实现类中的依赖注入配置 - 调整了统计拦截器和服务类中的依赖注入策略 - 优化了 FaceService 和相关 Repository 的注入方式 - 防止应用启动时因循环依赖导致的初始化失败
This commit is contained in:
@@ -6,6 +6,7 @@ import com.ycwl.basic.stats.service.StatsService;
|
||||
import com.ycwl.basic.stats.util.StatsUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.method.HandlerMethod;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
@@ -18,6 +19,7 @@ import java.util.HashSet;
|
||||
|
||||
@Component
|
||||
public class StatsInterceptor implements HandlerInterceptor {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private StatsService statsService;
|
||||
|
||||
|
||||
@@ -7,15 +7,18 @@ import com.ycwl.basic.stats.mapper.StatsMapper;
|
||||
import com.ycwl.basic.stats.mapper.StatsRecordMapper;
|
||||
import com.ycwl.basic.stats.service.StatsService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Service
|
||||
public class StatsServiceImpl implements StatsService {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private StatsMapper statsMapper;
|
||||
|
||||
@Lazy
|
||||
@Autowired
|
||||
private StatsRecordMapper statsRecordMapper;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user