![](/img/trans.png)
[英]Configure Spring Security AuthenticationManager without spring-boot-starter-web
[英]How can I get an ObjectMapper instance in Spring Boot without inheriting from spring-boot-starter-web?
我正在玩Spring Boot 2.0.0M2,試圖創建一個CLI應用程序,而不是一個Web應用程序。 我的問題是甚至包括
compile 'org.springframework.boot:spring-boot-starter'
compile 'org.springframework.boot:spring-boot-starter-json'
在我的構建中,ObjectMapper不是由Boot創建的
Bean method 'jacksonObjectMapper' not loaded because @ConditionalOnClass did not find required class 'org.springframework.http.converter.json.Jackson2ObjectMapperBuilder'
當您想要Spring Boot實例並配置Jackson而不想啟動Web服務器時,最佳做法是什么?
你為什么不自己初始化它。
@Bean
ObjectMapper objectMapper() {
return new ObjectMapper();
}
如果要避免包含完整的Web堆棧(從Spring Boot v.2.0.0M4開始),可以添加spring-boot-starter-json
。
您可以嘗試並添加org.springframework:spring-web
依賴,因為該類位於其中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.