Ser*_*del 5 spring spring-mvc jackson spring-boot jackson-databind
我在玩Spring Boot 2.0.0M2,试图创建一个CLI应用程序,而不是一个Web应用程序。我的问题是,即使包括
compile 'org.springframework.boot:spring-boot-starter'
compile 'org.springframework.boot:spring-boot-starter-json'
Run Code Online (Sandbox Code Playgroud)
在我的构建中,ObjectMapper不是由Boot创建的,因为
Bean method 'jacksonObjectMapper' not loaded because @ConditionalOnClass did not find required class 'org.springframework.http.converter.json.Jackson2ObjectMapperBuilder'
Run Code Online (Sandbox Code Playgroud)
当您想拥有Spring Boot实例并配置Jackson而又不想启动Web服务器时,最佳实践是什么?
你为什么不自己初始化它。
@Bean
ObjectMapper objectMapper() {
return new ObjectMapper();
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3362 次 |
| 最近记录: |