简体   繁体   English

考虑在你的配置中定义一个 'com.test.simpletest.mapper.PersonMapper' 类型的 bean

[英]Consider defining a bean of type 'com.test.simpletest.mapper.PersonMapper' in your configuration

Error apears when runing the application: Consider defining a bean of type 'com.test.simpletest.mapper.PersonMapper' in your configuration.运行应用程序时出现错误:考虑在配置中定义类型为“com.test.simpletest.mapper.PersonMapper”的 bean。

EntityMapper:实体映射器:

public interface EntityMapper<D, E> {
    D toDTO(E entity);

    E toDAO(D dto);
}

PersonMapper:人物映射器:

@Mapper
public interface PersonMapper extends EntityMapper<PersonDTO, Person> {
}

PersonService:人员服务:

public interface PersonService {
    List<Person> getAllPersons();
    Person createPerson(Person person);
}

PersonImpl: PersonImpl:

@Service
public class PersonImpl implements PersonService {

    private PersonRepository personRepository;
    private PersonMapper personMapper;

    public PersonImpl(PersonRepository personRepository, PersonMapper personMapper) {
        this.personRepository = personRepository;
        this.personMapper = personMapper;
    }

    @Override
    public List<Person> getAllPersons() {
        return personRepository.findAll();
    }


    @Override
    public Person createPerson(Person person) {
        return  personRepository.save(person);
    } 
}

Change @Mapper to @Mapper(componentModel = "spring") .@Mapper更改为@Mapper(componentModel = "spring") Then it will be correctly used by spring as a bean.然后它将被 spring 正确用作 bean。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 考虑在您的配置中定义类型为“ com.face.ImageRepository”的bean? - Consider defining a bean of type 'com.face.ImageRepository' in your configuration? 考虑在您的配置中定义类型为“com.repository.UserRepository”的 bean - Consider defining a bean of type 'com.repository.UserRepository' in your configuration 考虑在配置中定义类型为&#39;com.test.project.repositories.TaskRepository&#39;的bean @Repository注解已经存在 - Consider defining a bean of type 'com.test.project.repositories.TaskRepository' in your configuration @Repository annotation is already there 考虑在您的配置中定义一个类型的 bean - Consider defining a bean of type in your configuration 例外:考虑在你的配置中定义一个类型的 bean - Exception: Consider defining a bean of type in your configuration 考虑在您的配置中定义类型为“UserConverter”的 bean - Consider defining a bean of type 'UserConverter' in your configuration 考虑在你的配置中定义一个类型为 * 的 bean - Consider defining a bean of type * in your configuration 考虑在配置中定义“包”类型的bean - Consider defining a bean of type 'package' in your configuration 考虑在你的配置中定义一个 'form' 类型的 bean - Consider defining a bean of type 'form' in your configuration 考虑在配置问题中定义类型的 bean - Consider defining a bean of type in your configuration issue
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM