java - MapStruct - 第二个映射器的焊接注射不起作用
问题描述
我在使用 mapstruct 库的映射器的焊接 cdi 中注入问题。当我只有一个映射器时,一切正常。添加第二个映射器后,此映射器抛出异常: 原因:org.jboss.weld.exceptions.DeploymentException: WELD-001408: 带有限定符 @Default 的 InspectionTypeMapper 类型的依赖关系不满足
第一个映射器(这个映射器工作)
@Mapper(componentModel = "cdi", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface InstallationMapper {
Installation installationDtoToInstallation(InstallationDto installationDto);
InstallationDto installationToInstallationDto(Installation installation);
List<InstallationDto> installationsToInstallationsDtos(List<Installation> installations);
}
第二个映射器(这不起作用并抛出异常):
@Mapper(componentModel = "cdi", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface InspectionTypeMapper {
InspectionType inspectionTypeDtoToInspectionType(InspectionTypeDto inspectionTypeDto);
InspectionTypeDto inspectionTypeToInspectionTypeDto(InspectionType inspectionType);
List<InspectionTypeDto> inspectionTypesToInspectionTypeDtos(List<InspectionType> inspectionTypes);
}
我的安装ServiceImpl:
@RequestScoped
public class InstallationServiceImpl implements InstallationService {
@Inject
private InstallationRepository installationRepository;
@Inject
private InstallationMapper installationMapper;
@Override
public List<InstallationDto> getAllInstallations() {
List<Installation> installations = installationRepository.getAll();
List<InstallationDto> installationDtos = installationMapper.installationsToInstallationsDtos(installations);
return installationDtos;
}
}
我的 InspectionTypeServiceImpl:
@RequestScoped
public class InspectionTypeServiceImpl implements InspectionTypeService{
@Inject
InspectionTypeRepository inspectionTypeRepository;
@Inject
InspectionTypeMapper inspectionTypeMapper;
@Override
public List<InspectionTypeDto> getAllInspectionTypes() {
List<InspectionType> inspectionTypes = inspectionTypeRepository.getAll();
System.out.println(inspectionTypes);
List<InspectionTypeDto> inspectionTypeDtos = inspectionTypeMapper
.inspectionTypesToInspectionTypeDtos(inspectionTypes);
return inspectionTypeDtos;
}
解决方案
推荐阅读
- mongodb - 如何使用当前时间和文档中的另一个字段创建 mongodb 查询?
- java - 使用 eclipse 生成 .jar 文件后如何加载图像?
- sql-server - 从 SSMS 2008 迁移到 SSMS 2016 后,数据库服务器面临缓慢的问题
- html -
- 如何将导航栏中的最后一项设置在右侧
- kubernetes-ingress - 通过使用 Istio 端点身份验证,使用 Firebase 对 JWT 进行身份验证
- clips - CLIPS 无法识别 deftemplate 名称
- javascript - 我没有在素数函数中得到平方循环索引
- php - 发送邮件后重定向不起作用 | Laravel
- javascript - 在 JSON 文件中仅加载 2000 个结果中的 500 个,并带有附加加载更多按钮
- python - 在 Pytorch 中有效地增强带边框的 PIL 图像