I want to deploy WAR file, created from Spring Boot project, in Tomcat 7. I followed instructions from official Spring page link. If i understood correctly there are 3 steps to be done in order to create WAR file successfully:
- Extend main class with SpringBootServletInitializer and override configure method
- In pom.xml set packaging to 'war'
- In pom.xml mark the embedded servlet container dependency as provided.
After i did all these steps i created WAR file successfully and deployed it to Tomcat 7(localhost), anyhow my controller is not reachable, HTTP Status 404. If i run it with embedded settings i am able to reach controller method.
In addition please see bellow my 'Main' class and pom.xml.
Main class:
@ComponentScan(basePackages="com.sekulicd")
@EnableWebMvc
@Import(DatabaseConfig.class)
@SpringBootApplication
public class RunApplication extends SpringBootServletInitializer
{
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(RunApplication.class);
}
public static void main(String[] args)
{
SpringApplication.run(RunApplication.class, args);
}
}
pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.sekulicd</groupId>
<artifactId>SpringBoot</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.7.RELEASE</version>
</parent>
<properties>
<start-class>com.sekulicd.boot.RunApplication.java</start-class>
</properties>
<dependencies>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>3.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-couchbase</artifactId>
</dependency>
</dependencies>
<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>http://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>spring-releases</id>
<url>https://repo.spring.io/libs-release</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-releases</id>
<url>https://repo.spring.io/libs-release</url>
</pluginRepository>
</pluginRepositories>
<build>
<finalName>Test</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<jvmArguments>
-Xdebug
-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
</jvmArguments>
</configuration>
</plugin>
</plugins>
</build>
</project>
If anybody have an idea if i missed something or did something wrong please advise.