title: How to run the imported Spring mvc project in Intellij?
body: <p>I am using IntelliJ and imported the Spring MVC project.I configured the maven setup and used <code>mvn clean install</code>  to build my project.And for running I configured tomcat:run on the configuration of IntelliJ. But red markers are shown as:</p>
  
  <p><a href="https://i.stack.imgur.com/No993.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/No993.png" alt="enter image description here"></a> </p>
  
  <pre><code>&lt;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"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
      &lt;groupId&gt;com.luv2code&lt;/groupId&gt;
      &lt;artifactId&gt;spring-security-demo&lt;/artifactId&gt;
      &lt;version&gt;1.0&lt;/version&gt;
      &lt;packaging&gt;war&lt;/packaging&gt;
  
      &lt;name&gt;spring-security-demo&lt;/name&gt;
  
      &lt;properties&gt;
          &lt;springframework.version&gt;5.0.2.RELEASE&lt;/springframework.version&gt;
  
          &lt;maven.compiler.source&gt;1.8&lt;/maven.compiler.source&gt;
          &lt;maven.compiler.target&gt;1.8&lt;/maven.compiler.target&gt;
      &lt;/properties&gt;
  
      &lt;dependencies&gt;
  
          &lt;!-- Spring MVC support --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-webmvc&lt;/artifactId&gt;
              &lt;version&gt;${springframework.version}&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;!-- Servlet, JSP and JSTL support --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
              &lt;artifactId&gt;javax.servlet-api&lt;/artifactId&gt;
              &lt;version&gt;3.1.0&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;javax.servlet.jsp&lt;/groupId&gt;
              &lt;artifactId&gt;javax.servlet.jsp-api&lt;/artifactId&gt;
              &lt;version&gt;2.3.1&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
              &lt;artifactId&gt;jstl&lt;/artifactId&gt;
              &lt;version&gt;1.2&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;junit&lt;/groupId&gt;
              &lt;artifactId&gt;junit&lt;/artifactId&gt;
              &lt;version&gt;3.8.1&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
  
      &lt;/dependencies&gt;
  
      &lt;!-- TO DO: Add support for Maven WAR Plugin --&gt;
      &lt;build&gt;
          &lt;finalName&gt;spring-security-demo&lt;/finalName&gt;
          &lt;pluginManagement&gt;
               &lt;plugins&gt;
                   &lt;plugin&gt;
                       &lt;!-- Add maven coordinate for maven war plugin--&gt;
                       &lt;!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-war-plugin --&gt;
  
                           &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                           &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt;
                           &lt;version&gt;3.2.3&lt;/version&gt;
  
  
                   &lt;/plugin&gt;
               &lt;/plugins&gt;
          &lt;/pluginManagement&gt;
      &lt;/build&gt;
  
  &lt;/project&gt;
  </code></pre>
  
  <p>But it is successfully compiling and while running consoles printed are:</p>
  
  <blockquote>
    <p>"C:\Program Files\Java\jdk1.8.0_111\bin\java.exe"
    -Dmaven.multiModuleProjectDirectory=C:\Users\AshwinPC\Desktop\Spring-Security\spring-security-demo-starter\spring-security-demo-01-base-app
    "-Dmaven.home=C:\Program Files\JetBrains\IntelliJ IDEA Community
    Edition 2019.2\plugins\maven\lib\maven3"
    "-Dclassworlds.conf=C:\Program Files\JetBrains\IntelliJ IDEA Community
    Edition 2019.2\plugins\maven\lib\maven3\bin\m2.conf"
    "-Dmaven.ext.class.path=C:\Program Files\JetBrains\IntelliJ IDEA
    Community Edition 2019.2\plugins\maven\lib\maven-event-listener.jar"
    "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition
    2019.2\lib\idea_rt.jar=61598:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.2\bin" -Dfile.encoding=UTF-8 -classpath
    "C:\Program Files\JetBrains\IntelliJ IDEA Community Edition
    2019.2\plugins\maven\lib\maven3\boot\plexus-classworlds-2.6.0.jar" org.codehaus.classworlds.Launcher -Didea.version2019.2 tomcat:run
    [INFO] Scanning for projects... [INFO]  [INFO] -----------------&lt;
    com.luv2code:spring-security-demo >------------------ [INFO] Building
    spring-security-demo 1.0 [INFO] --------------------------------[ war
    ]--------------------------------- [INFO]  [INFO] >>>
    tomcat-maven-plugin:1.1:run (default-cli) > compile @
    spring-security-demo >>> [INFO]  [INFO] ---
    maven-resources-plugin:2.6:resources (default-resources) @
    spring-security-demo --- [WARNING] Using platform encoding (UTF-8
    actually) to copy filtered resources, i.e. build is platform
    dependent! [INFO] skip non existing resourceDirectory
    C:\Users\AshwinPC\Desktop\Spring-Security\spring-security-demo-starter\spring-security-demo-01-base-app\src\main\resources
    [INFO]  [INFO] --- maven-compiler-plugin:3.1:compile (default-compile)
    @ spring-security-demo --- [INFO] Nothing to compile - all classes are
    up to date [INFO]  [INFO] &lt;&lt;&lt; tomcat-maven-plugin:1.1:run
    (default-cli) &lt; compile @ spring-security-demo &lt;&lt;&lt; [INFO]  [INFO] 
    [INFO] --- tomcat-maven-plugin:1.1:run (default-cli) @
    spring-security-demo --- [INFO] Running war on
    <a href="http://localhost:8080/spring-security-demo" rel="nofollow noreferrer">http://localhost:8080/spring-security-demo</a> [INFO] Creating Tomcat
    server configuration at
    C:\Users\AshwinPC\Desktop\Spring-Security\spring-security-demo-starter\spring-security-demo-01-base-app\target\tomcat
    Aug 09, 2019 10:49:23 AM org.apache.catalina.startup.Embedded start
    INFO: Starting tomcat server Aug 09, 2019 10:49:23 AM
    org.apache.catalina.core.StandardEngine start INFO: Starting Servlet
    Engine: Apache Tomcat/6.0.29 Aug 09, 2019 10:49:24 AM
    org.apache.coyote.http11.Http11Protocol init INFO: Initializing Coyote
    HTTP/1.1 on http-8080 Aug 09, 2019 10:49:24 AM
    org.apache.coyote.http11.Http11Protocol start INFO: Starting Coyote
    HTTP/1.1 on http-8080</p>
  </blockquote>
  
  <p>And when I hit :<code>http://localhost:8080/spring-security-demo/</code></p>
  
  <p><a href="https://i.stack.imgur.com/mVffa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mVffa.png" alt="enter image description here"></a></p>
  
  <p>Other configuration classes are:</p>
  
  <p>DemoController.java </p>
  
  <pre><code>  package com.luv2code.springsecurity.demo.controller;
  
  
      import org.springframework.stereotype.Controller;
      import org.springframework.web.bind.annotation.GetMapping;
  
      @Controller
      public class DemoController {
  
          @GetMapping("/")
          public String showHome(){
              return "home";
          }
  
  
      }
  </code></pre>
  
  <p>Config class:</p>
  
  <pre><code>package com.luv2code.springsecurity.demo.config;
  
  import org.springframework.context.annotation.Bean;
  import org.springframework.context.annotation.ComponentScan;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.web.servlet.ViewResolver;
  import org.springframework.web.servlet.config.annotation.EnableWebMvc;
  import org.springframework.web.servlet.view.InternalResourceViewResolver;
  
  @Configuration
  @EnableWebMvc
  @ComponentScan(basePackages = "com.luv2code")
  public class DemoAppConfig {
  
      //bean for viewresolver
      @Bean
      public ViewResolver viewResolver(){
          InternalResourceViewResolver viewResolver=new InternalResourceViewResolver();
          viewResolver.setPrefix("/WEB-INF/view/");
          viewResolver.setSuffix(".jsp");
          return viewResolver;
      }
  
  
  
  
  }
  </code></pre>
  
  <p>Dispatcher Servlet config</p>
  
  <pre><code>package com.luv2code.springsecurity.demo.config;
  
  
  import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
  
  public class MySpringMVcDispatcherServletInitilizer extends AbstractAnnotationConfigDispatcherServletInitializer {
  
  
      @Override
      protected Class&lt;?&gt;[] getRootConfigClasses(){
           return null;
      }
  
      @Override
      protected Class&lt;?&gt;[] getServletConfigClasses(){
            return  new Class[] {DemoAppConfig.class};
      }
  
      @Override
      protected  String[] getServletMappings(){
          return new String[] { "/" };
      }
  
  
  }
  </code></pre>