具體的提示信息以下:java
Error:(21, 8) java: cannot access org.springframework.web.WebApplicationInitializer
class file for org.springframework.web.WebApplicationInitializer not foundweb
這個錯誤要結合你的 Application 代碼來看。spring
由於在 Application 的代碼中,咱們繼承了 SpringBootServletInitializer。spring-boot
請注意:咱們定義的 Application:gradle
public class Application extends SpringBootServletInitializer{
}ui
正是由於這個定義,因此你的 POM 或者 build.gradle 中 須要添加:spring-boot-starter-web 依賴。spa
<dependency>code
<groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <version>2.2.6.RELEASE</version>
</dependency>blog
而後你再次編譯的項目,你就不會有提示編譯錯誤了。繼承
https://www.cwiki.us/display/SpringBootZH/questions/57939020