Spring boot 中的自动装配字段为空

问题描述 投票:0回答:1

当前正在使用此包 com.walmart.sams.services.allocation.configuration.service.strategy。但是当我从这个包 com.walmart.sams.services.allocation.configuration.service.repo 自动装配 repo 对象时,它为空。有人可以解释一下吗?它只发生在策略包中。

Repo 类如下所示:

public interface ItemClubConfigRepository extends BaseRepository<ItemClubConfig, Long> {
    
    List<ItemClubConfig> findAllByItemNbrInAndTenantIdAndItemType(Set<Integer> itemNbrs, String tenantId, String itemType);
    }
spring-boot package nullpointerexception autowired
1个回答
0
投票

@Service
注释图像中显示的服务,如果您使用 Lombok,只需添加
@AllArgsConstructor
那么您应该能够注入您的服务。另外,请确保您注入的服务带有
@Service
@Component
@Configuration

注释
© www.soinside.com 2019 - 2024. All rights reserved.