I have created the required configurations/controller classes. But it's not clear to me how I should orchestrate these classes to use run a tomcat instance. I know with spring boot it's a matter of using SpringApplication.run(..). But I'm trying to explore the alternate method used prior to Spring Boot. I'm a bit new to the Spring Framework so forgive my ignorance. I'm also not using any XML configuration only using Java
public class SpittrWebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer
{
@Override //....
protected String[] getServletMappings(){
return new String[] { "/" };
}
@Override //...
protected Class<?>[] getRootConfigClasses(){
return new Class<?>[] { RootConfig.class };
}
@Override //.....
protected Class<?>[] getServletConfigClasses(){
return new Class<?>[] { WebConfig.class };
}
}
I have created a controller
@Controller
@RequestMapping("/")
public class HomeController {
@RequestMapping(method = RequestMethod.GET)
public String home(){
return "home";
}
POM File:
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.3.9.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.3.9.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.3.9.RELEASE</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>4.3.9.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
</dependencies>