我在玩 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 服务器时,最佳实践是什么?
最佳答案
您可以添加 spring-boot-starter-json
如果您想避免包含完整的 Web 堆栈(自 Spring Boot v.2.0.0M4 起)。
关于spring - 如何在不继承 spring-boot-starter-web 的情况下在 Spring Boot 中获取 ObjectMapper 实例?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44807747/