只需要引入如下依赖即可: 1.首先判断容器的类型,这里是servlet类型 org.springframework.boot.WebApplicationType#deduceFromClasspath 2...