I\'m getting SpringBootServletInitializer cannot be resolved to a type
as far as I understand this is a dependencies issue.
While I feel comfortable wri
I encountered the same problem ... but I'm using Maven with Spring Boot 2.1.1.
So I needed to specify the correct parent ... AND change the import/class name:
pom.xml:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.1.RELEASE</version>
</parent>
MyApp.java:
...
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
// import org.springframework.boot.web.support.SpringBootServletInitializer; // OBSOLETE
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
@SpringBootApplication
public class SpringBootWebApplication extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(SpringBootWebApplication.class);
}
public static void main(String[] args) throws Exception {
SpringApplication.run(SpringBootWebApplication.class, args);
}
...
I had the same issue.My solution is
instead of
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
use
import org.springframework.boot.web.support.SpringBootServletInitializer;
Also in pom
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.6.RELEASE</version>
</parent>
Don't do anything new just press Ctrl+Shift+o in your eclipse it will add correct import to your project
I'm following the same course and I just set the pom like this:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.6.RELEASE</version>
</parent>
And works fine