Here is the question how to configure Spring MVC in SpringBoot Application.

SpringBoot solution is minimal configuration for integration of SpringModules.

A Complete integration and code clean up as per advance provided by Spring Boot.

  1. No web.xml & dispatcher-servlet.xml
  2. Required a main  class ( extends SpringBootServletInitializer )
  3.  Invoke static run method in SpringApplication

Spring Boot provides simple steps it involves following steps:

1. Add
2. Configure Spring Application class.
3. Invoke SpringApplication class
Thats All !!

Lets have look into it how to do practically.

  1. Add under resources.
# Add below properties 
# View resolver settings as below
spring.mvc.view.prefix: /WEB-INF/view/
spring.mvc.view.suffix: .jsp
server.port: 9999

# Custom messages can be configured as below
welcome.message: Hello Techie !! Welcome to Spring Boot.

Message can be read in the Controller  as below.

private String message = "Hello World";

               2. Configure the Application Class

import org.springframework.boot.SpringApplication;  
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;        
import org.springframework.boot.autoconfigure.SpringBootApplication;        
import org.springframework.boot.builder.SpringApplicationBuilder;        
import org.springframework.context.annotation.ComponentScan; 
@ComponentScan({ "" })  
public class ApplicationRunner extends SpringBootServletInitializer { 
	protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {            
            return application.sources(ApplicationRunner.class);        
	public static void main(String[] args) {        
  , args);        

3. Run ApplicationRunner class:

Now Spring Boot will perform the action internally.

  1. Invokes configured web server. Here it is tomcat. org.springframework.boot spring-boot-starter-tomcat provided
  2. Webserver will run with application with out context path.
  3. Services can be accessed with actions or mapping name directly.
    localhost:8080 // will results in default page.
    localhost:8080/response // will find the service mapped with "response"

Hope it helps, Thanks for reading post !!