形式自動裝配工作的跟進to this question爲什麼不把這些在@Configuration
我也嘗試過這一點,但它不具有noargs構造函數(你現在可以通過服務/控制器/組件做到這一點炸燬,那麼爲什麼不能在這裏工作嗎?)
@Configuration
class MyConfig {
@Autowired
MyConfig(final ObjectMapper mapper) {
...
}
}
,但這個工程
@Configuration // or @Service or some bean
class SomeClass ... {
@Autowired
private ObjectMapper objectMapper;
@PostConstruct
private void configureObjectMapper() {
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
}
}
爲什麼不@Configuration
工作像其它的管理類?
請告訴我們你如何使用配置。一個mcve。 –
@SotiriosDelimanolis一個什麼?鏈接的問題包含更多的信息......但它們是@配置,它們是自動加載的,沒有直接的用法。 Spring Rest和Spring MVC使用'ObjectMapper'。 – xenoterracide
OP,請注意您拼錯了註釋名稱。 – chrylis