繁体   English   中英

如何在非 Web Spring 环境中自动配置 ConversionService?

[英]How to auto-configure ConversionService in non-web Spring environment?

我有一个带有spring-boot的非网络环境,因为我只需要一些类:

spring.main.web-application-type=none

问题:我如何告诉 spring 自动配置org.springframework.core.convert.ConversionService (例如,我需要@Entity对象的@Convert自动映射)?

当我尝试自动连接对话服务时,它失败了:

@Autowired
private ConversionService conversionService;

public void fetch() {
     BeanPropertyRowMapper.newInstance(MyObject.class, conversionService));
}

required a bean of type 'org.springframework.core.convert.ConversionService' that could not be found.

您可以自动装配 ConfigurableEnvironment 并从那里获取转换服务。 如果您想直接使其可用,请将其放入 Bean 方法中。

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM