小编lum*_*umi的帖子

如何在springboot中的ConversionService中自动装配

试图在springboot中访问模型中的ConversionControl,没有运气.

@Component
public class CityHelperService  {

    @Autowired
    ConversionService conversionService;// = ConversionServiceFactory.registerConverters();

    public City toEntity(CityDTO dto){
        City entity = conversionService.convert(dto, City.class);
        return entity;
    }

    public CityDTO toDTO(City entity){
        CityDTO dto = conversionService.convert(entity, CityDTO.class);
        return dto;
    }
}
Run Code Online (Sandbox Code Playgroud)

它显示以下错误:

Injection of autowired dependencies failed;
nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.lumiin.mytalk.model.CityModel com.lumiin.mytalk.controllers.CityController.cityModel;
nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'cityModel' defined in file : Unsatisfied dependency expressed through constructor argument with index 1 of type [com.lumiin.mytalk.dao.CityHelperService]: : Error …
Run Code Online (Sandbox Code Playgroud)

java spring spring-mvc spring-boot

9
推荐指数
1
解决办法
1万
查看次数

标签 统计

java ×1

spring ×1

spring-boot ×1

spring-mvc ×1