I was trying to package a spring boot application as a war. According to this, I modified my Application class:
@SpringBootApplication
@EntityScan({"org.mdacc.rists.cghub.model"})
@EnableJpaRepositories(basePackages = {"org.mdacc.rists.cghub.ws.repository"})
public class Application extends SpringBootServletInitializer
{
public static void main( String[] args )
{
SpringApplication.run(Application.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
}
}
Also added the following in my pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
When I package the project though, I got the following error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.2:war (default-war) on project cg-web: Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode) -> [Help 1]
As I was reading upon spring boot application, I never saw anything about creating a web.xml. Is web.xml required in deploying spring boot application as war?
According to this answer make Maven ignore the web.xml absence by adding the following snippet to your pom.xml:
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>