【发布时间】:2020-09-15 02:58:42
【问题描述】:
我以前从未使用过CommandLineRunner,因为我一直在编写 Web 服务器。这次我正在构建一个微服务(CRON 作业),它会唤醒,进行一些休息和数据库调用,然后停止。
对于这个项目,和其他项目一样,最初我有以下依赖项:
implementation "org.springframework.boot:spring-boot-starter-web:$springBootVersion"
直到我发现有一个叫做 CommandLineRunner 的东西,并且由于我不需要运行 Web 服务器,我实际上可以通过 .setWebApplicationType(WebApplicationType.NONE); 将其关闭
现在我想知道如果我们关闭其网络服务器,包含 spring-boot-starter-web 的意义何在?我使用 Spring Boot 框架默认使用它的依赖项(比如 jackson 等)以及它的依赖项管理框架。
(旁注:我试图转移到sprint-boot-starter,但我无法解决以下问题,所以我想我继续使用spring-boot-starter-web:
Correct the classpath of your application so that it contains a single, compatible version of org.springframework.http.converter.json.Jackson2ObjectMapperBuilder)
【问题讨论】:
标签: spring-boot