Проблема с пружинной загрузкой с использованием MapstructJAVA

Программисты JAVA общаются здесь
Anonymous
Проблема с пружинной загрузкой с использованием Mapstruct

Сообщение Anonymous »

Я новичок в Spring Boot. Я надеюсь, что кто -то поможет мне понять, что я делаю не так.

Код: Выделить всё

@RequiredArgsConstructor
@Service
public class UserService {

private final UserRepository userRepository;

private final UserMapper userMapper;

public UserDto login(CredentialDto credentialDto) {
User user = userRepository.findBylogin(credentialDto.login())
.orElseThrow(()-> {
ApplicationException ex =new ApplicationException();
ex.setMessage("Unknown user");
return ex;
});
return userMapper.toUserDto(user);
}
}
< /code>
Мой класс Mapper: < /p>
@Mapper(componentModel = "spring")
public interface UserMapper {
UserDto toUserDto(User user);
}
Я получил ошибку в IDE, которая приведена ниже:
Описание:

Код: Выделить всё

Parameter 1 of constructor in com.example.jwttest.service.UserService required a bean of type 'com.example.jwttest.mappers.UserMapper' that could not be found.
action:

Код: Выделить всё

Consider defining a bean of type 'com.example.jwttest.mappers.UserMapper' in your configuration.
Очень ценит любую помощь.

Подробнее здесь: https://stackoverflow.com/questions/776 ... -mapstruct

Вернуться в «JAVA»