Every time I create a project from spring.io a ServletInitializer file is created inside the project. I only have the spring cloud gateway dependency. Is this the reason this file exists, and if yes, could someone please explain why?
These are its contents:
package com.springcloudgatewayexample;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
public class ServletInitializer extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(SpringCloudGatewayExampleApplication.class);
}
}
This is the case when you choose the packaging as WAR instead of the JAR while creating a project using SpringInitializr. If you will choose the packaging as JAR (which is selected by default), then only 1 class i.e. ApplicationClass having main method and @SpringBootApplication will be created.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With