Java – Spring boot “Whitelabel Error Page” No information available

Spring boot “Whitelabel Error Page” No information available… here is a solution to the problem.

Spring boot “Whitelabel Error Page” No information available

I’m trying to convert my Spring MVC project to Spring Boot. I converted all the necessary files according to Spring Boot. There are no errors on the console. But when I run my web app in my browser, I get this error.
Error: “Whitelabel Error Page” No message available
Please tell me why this error appears and how to fix it?

pageController.java

package net.kzn.onlineshopping.contr 

@Controller
public class PageController {

private static final Logger logger = LoggerFactory.getLogger(PageController.class);

@Autowired
    private CategoryDAO categoryDAO;

@Autowired
    private ProductDAO productDAO;

@RequestMapping(value = { "/", "/home", "/index" })
    public ModelAndView index(@RequestParam(name = "logout", required = false) String logout) {
        ModelAndView mv = new ModelAndView("page");
        mv.addObject("title", "Home");

logger.info("Inside PageController index method - INFO");
        logger.debug("Inside PageController index method - DEBUG");
  
 passing the list of categories
        mv.addObject("categories", categoryDAO.list());

if (logout != null) {
            mv.addObject("message", "You have successfully logged out!");
        }

mv.addObject("userClickHome", true);
        return mv;
    }

@RequestMapping(value = "/about")
    public ModelAndView about() {
        ModelAndView mv = new ModelAndView("page");
        mv.addObject("title", "About Us");
        mv.addObject("userClickAbout", true);
        return mv;
    }

@RequestMapping(value = "/contact")
    public ModelAndView contact() {
        ModelAndView mv = new ModelAndView("page");
        mv.addObject("title", "Contact Us");
        mv.addObject("userClickContact", true);
        return mv;
    }

/*
     * Methods to load all the products and based on category
     */

@RequestMapping(value = "/show/all/products")
    public ModelAndView showAllProducts() {
        ModelAndView mv = new ModelAndView("page");
        mv.addObject("title", "All Products");

 passing the list of categories
        mv.addObject("categories", categoryDAO.list());

mv.addObject("userClickAllProducts", true);
        return mv;
    }

@RequestMapping(value = "/show/category/{id}/products")
    public ModelAndView showCategoryProducts(@PathVariable("id") int id) {
        ModelAndView mv = new ModelAndView("page");

 categoryDAO to fetch a single category
        Category category = null;

category = categoryDAO.get(id);

mv.addObject("title", category.getName());

 passing the list of categories
        mv.addObject("categories", categoryDAO.list());

 passing the single category object
        mv.addObject("category", category);

mv.addObject("userClickCategoryProducts", true);
        return mv;
    }

/*
     * Viewing a single product
     */

@RequestMapping(value = "/show/{id}/product")
    public ModelAndView showSingleProduct(@PathVariable int id) throws ProductNotFoundException {

ModelAndView mv = new ModelAndView("page");

Product product = productDAO.get(id);

if (product == null)
            throw new ProductNotFoundException();

 update the view count
        product.setViews(product.getViews() + 1);
        productDAO.update(product);
        // ---------------------------

mv.addObject("title", product.getName());
        mv.addObject("product", product);

mv.addObject("userClickShowProduct", true);

return mv;

}

@RequestMapping(value = "/membership")
    public ModelAndView register() {
        ModelAndView mv = new ModelAndView("page");

logger.info("Page Controller membership called!");

return mv;
    }

@RequestMapping(value = "/login")
    public ModelAndView login(@RequestParam(name = "error", required = false) String error,
            @RequestParam(name = "logout", required = false) String logout) {
        ModelAndView mv = new ModelAndView("login");
        mv.addObject("title", "Login");
        if (error != null) {
            mv.addObject("message", "Username and Password is invalid!");
        }
        if (logout != null) {
            mv.addObject("logout", "You have logged out successfully!");
        }
        return mv;
    }

@RequestMapping(value = "/logout")
    public String logout(HttpServletRequest request, HttpServletResponse response) {
         Invalidates HTTP Session, then unbinds any objects bound to it.
         Removes the authentication from securitycontext
        Authentication auth = SecurityContextHolder.getContext().getAuthentication();
        if (auth != null) {
            new SecurityContextLogoutHandler().logout(request, response, auth);
        }

return "redirect:/login?logout";
    }

@RequestMapping(value = "/access-denied")
    public ModelAndView accessDenied() {
        ModelAndView mv = new ModelAndView("error");
        mv.addObject("errorTitle", "Aha! Caught You.");
        mv.addObject("errorDescription", "You are not authorized to view this page!");
        mv.addObject("title", "403 Access Denied");
        return mv;
    }

@RequestMapping(value = "/view/category/{id}/products")
    public ModelAndView viewProducts(@PathVariable("id") int id) {
        ModelAndView mv = new ModelAndView("page");
         categoryDAO to fetch a single category
        Category category = null;

category = categoryDAO.get(id);

mv.addObject("title", category.getName());

 passing the list of categories
        mv.addObject("viewproducts", productDAO.listActiveProductsByCategory(id));

mv.addObject("userClickViewProducts", true);
        return mv;
    }

@RequestMapping(value = "/search")
    public ModelAndView Search(@RequestParam(value = "searchTerm", required = false) String pSearchTerm,
            HttpServletRequest request, HttpServletResponse response) {
        ModelAndView mv = new ModelAndView("search");

mv.addObject("searchTerm", pSearchTerm);
        mv.addObject("searchResult", productDAO.searchProductsByParam(pSearchTerm));

mv.addObject("userClickSearch", true);

return mv;
    }

}

OnlineshoppingApplication.java

package net.kzn.onlineshopping;

@SpringBootApplication
@EnableWebSecurity 
@ComponentScan(basePackages = {"net.kzn.onlineshopping.*","net.kzn.shoppingbackend.*"})
@ImportResource({"classpath:spring-security.xml","classpath:/**/dispatcher-servlet.xml"})
public class OnlineshoppingApplication {

public static void main(String[] args) {
        SpringApplication.run(OnlineshoppingApplication.class, args);
    }
    
}

dispatcher-servlet.xml

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:wf="http://www.springframework.org/schema/webflow-config"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
    http://www.springframework.org/schema/beans
   http://www.springframework.org/schema/beans/spring-beans.xsd
   http://www.springframework.org/schema/context
   http://www.springframework.org/schema/context/spring-context.xsd
   http://www.springframework.org/schema/mvc
   http://www.springframework.org/schema/mvc/spring-mvc.xsd
   http://www.springframework.org/schema/webflow-config
   http://www.springframework.org/schema/webflow-config/spring-webflow-config.xsd">

<context:component-scan
        base-package="net.kzn.onlineshopping" />

<bean id="viewResolver"
        class="org.springframework.web.servlet.view.InternalResourceViewResolver">

<property name="prefix" value="/WEB-INF/views/" />
        <property name="suffix" value=".jsp" />
    </bean>

<!-- id must be multipartResolver -->
    <bean id="multipartResolver"
        class="org.springframework.web.multipart.support.StandardServletMultipartResolver" />

<!-- Loading static resources -->
    <mvc:annotation-driven />
    <mvc:resources location="/assets/"
        mapping="/resources/**" />

<!-- WEBFLOW CONFIGURATION -->
    <!-- Entry point for the flow -->

<wf:flow-executor id="flowExecutor"
        flow-registry="flowRegistry" />

<wf:flow-registry id="flowRegistry"
        base-path="/WEB-INF/views/flows"
        flow-builder-services="flowBuilderServices">
        <wf:flow-location-pattern
            value="/**/*-flow.xml" />
    </wf:flow-registry>

<wf:flow-builder-services
        id="flowBuilderServices" view-factory-creator="viewFactoryCreator"
        validator="validator" />

<bean
        class="org.springframework.webflow.mvc.servlet.FlowHandlerAdapter">
        <property name="flowExecutor" ref="flowExecutor" />
    </bean>

<bean
        class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping">
        <property name="flowRegistry" ref="flowRegistry" />
        <property name="order" value="-1" />
    </bean>

<bean id="viewFactoryCreator"
        class="org.springframework.webflow.mvc.builder.MvcViewFactoryCreator">
        <property name="viewResolvers" ref="viewResolver" />
    </bean>

<!-- validator bean -->

<bean id="validator"
        class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean" />
</beans>

pom.xml

            <?xml version="1.0" encoding="UTF-8"?>
        <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>net.kzn</groupId>
            <artifactId>shoppingbackend</artifactId>
            <version>0.0.1-SNAPSHOT</version>
            <packaging>jar</packaging>

<name>shoppingbackend</name>
            <description>Demo project for Spring Boot</description>

<parent>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-parent</artifactId>
                <version>1.5.17.RELEASE</version>
                <relativePath /> <!-- lookup parent from repository -->
            </parent>

<properties>
                <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
                <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
                <java.version>1.8</java.version>
            </properties>

<dependencies>

<dependency>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-actuator</artifactId>
                </dependency>
                <dependency>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-data-elasticsearch</artifactId>
                </dependency>
                <dependency>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-data-jpa</artifactId>
                </dependency>
                <dependency>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-web</artifactId>
                </dependency>

<dependency>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-test</artifactId>
                    <scope>test</scope>
                </dependency>

<dependency>
                    <groupId>org.springframework.data</groupId>
                    <artifactId>spring-data-rest-hal-browser</artifactId>
                </dependency>

<!-- https://mvnrepository.com/artifact/org.springframework.webflow/spring-webflow -->
                <dependency>
                    <groupId>org.springframework.webflow</groupId>
                    <artifactId>spring-webflow</artifactId>
                    <version>2.5.1.RELEASE</version>
                </dependency>
                <dependency>
                <groupId>net.java.dev.jna</groupId>
                <artifactId>jna</artifactId>
                <version>4.2.2</version>
                </dependency>

<!-- Hibernate Dependency -->
                <dependency>
                    <groupId>org.hibernate</groupId>
                    <artifactId>hibernate-core</artifactId>
                    <version>5.2.7.Final</version>
                </dependency>
                
<!-- database connection pooling -->
                <dependency>
                    <groupId>org.apache.commons</groupId>
                    <artifactId>commons-dbcp2</artifactId>
                    <version>2.1.1</version>
                    <exclusions>
                        <exclusion>
                            <groupId>commons-logging</groupId>
                            <artifactId>commons-logging</artifactId>
                        </exclusion>
                    </exclusions>
                </dependency>

<dependency>
                    <groupId>com.h2database</groupId>
                    <artifactId>h2</artifactId>
                    <scope>runtime</scope>
                </dependency>
            </dependencies>

<build>
                <plugins>
                    <plugin>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-maven-plugin</artifactId>
                    </plugin>
                </plugins>

<resources>
                <resource>
                  <directory>src/main/webapp</directory>
                </resource>
              </resources>
            </build>

</project>

Console

        22:08:10.893 [main] DEBUG org.springframework.boot.devtools.settings.DevToolsSettings - Included patterns for restart : []
    22:08:10.897 [main] DEBUG org.springframework.boot.devtools.settings.DevToolsSettings - Excluded patterns for restart : [/spring-boot-actuator/target/classes/, / spring-boot-devtools/target/classes/, /spring-boot/target/classes/, /spring-boot-starter-[\w-]+/, /spring-boot-autoconfigure/target/classes/, /spring-boot-starter/target/ classes/]
    22:08:10.898 [main] DEBUG org.springframework.boot.devtools.restart.ChangeableUrls - Matching URLs for reloading : [file:/home/vidyesh/Downloads/spring-boot/onlineshopping/ target/classes/, file:/home/vidyesh/Downloads/spring-boot/shoppingbackend/target/classes/]
    2018-11-21 22:08:11.600  INFO 3913 --- [  restartedMain] n.k.o.OnlineshoppingApplication          : Starting OnlineshoppingApplication on vidyesh-SVE15115ENB with PID 3913  (/home/vidyesh/Downloads/spring-boot/onlineshopping/target/classes started by vidyesh in /home/vidyesh/Downloads/spring-boot/onlineshopping)
    2018-11-21 22:08:11.603  INFO 3913 --- [  restartedMain] n.k.o.OnlineshoppingApplication          : No active profile set, falling back to default profiles: default
    2018-11-21 22:08:11.788  INFO 3913 --- [  restartedMain] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context. AnnotationConfigServletWebServerApplicationContext@13fed3ea: startup date [Wed Nov 21 22:08:11 IST 2018]; root of context hierarchy
    2018-11-21 22:08:13.963  INFO 3913 --- [  restartedMain] o.s.b.f.xml.XmlBeanDefinitionReader      : Loading XML bean definitions from class path resource [spring-security.xml]
    2018-11-21 22:08:14.221  INFO 3913 --- [  restartedMain] o.s.s.core.SpringSecurityCoreVersion     : You are running with Spring Security Core 5.0.9.RELEASE
    2018-11-21 22:08:14.227  INFO 3913 --- [  restartedMain] o.s.s.config.SecurityNamespaceHandler    : Spring Security 'config' module version is 5.0.9.RELEASE
    2018-11-21 22:08:14.271  INFO 3913 --- [  restartedMain] o.s.b.f.s.DefaultListableBeanFactory     : Overriding bean definition for bean 'requestDataValueProcessor' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.security.config.annotation.web.configuration.WebMvcSecurityConfiguration; factoryMethodName=requestDataValueProcessor; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebMvcSecurityConfiguration.class]] with [Root bean: class [ org.springframework.security.web.servlet.support.csrf.CsrfRequestDataValueProcessor]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null]
    2018-11-21 22:08:14.294  INFO 3913 --- [  restartedMain] erInvocationSecurityMetadataSourceParser : Creating access control expression attribute 'hasAuthority('ADMIN')' for /manage/**
    2018-11-21 22:08:14.297  INFO 3913 --- [  restartedMain] erInvocationSecurityMetadataSourceParser : Creating access control expression attribute 'hasAuthority('USER')' for /cart/**
    2018-11-21 22:08:14.298  INFO 3913 --- [  restartedMain] erInvocationSecurityMetadataSourceParser : Creating access control expression attribute 'permitAll' for /**
    2018-11-21 22:08:14.352  INFO 3913 --- [  restartedMain] s.s.c.h.HttpSecurityBeanDefinitionParser : Checking sorted filter chain: [Root bean: class [ org.springframework.security.web.context.SecurityContextPersistenceFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 200, Root bean: class [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 400, Root bean: class [org.springframework.security.web.header.HeaderWriterFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 500, Root bean: class [org.springframework.security.web.csrf.CsrfFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 700, <org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0>, order = 1200, Root bean: class [ org.springframework.security.web.savedrequest.RequestCacheAwareFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 1700, Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.security.config.http.HttpConfigurationBuilder$SecurityContextHolderAwareRequestFilterBeanFactory#0; factoryMethodName=getBean; initMethodName=null; destroyMethodName=null, order = 1800, Root bean: class [org.springframework.security.web.authentication.AnonymousAuthenticationFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 2100, Root bean: class [org.springframework.security.web.session.SessionManagementFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 2200, Root bean: class [org.springframework.security.web.access.ExceptionTranslationFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 2300, <org.springframework.security.web.access.intercept.FilterSecurityInterceptor#0>, order = 2400]
    2018-11-21 22:08:16.825  INFO 3913 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'hibernateConfig' of type [net.kzn.shoppingbackend.config. HibernateConfig$$EnhancerBySpringCGLIB$$5feb6d4c] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
    2018-11-21 22:08:17.159  INFO 3913 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.ws.config.annotation.DelegatingWsConfiguration' of type [org.springframework.ws.config.annotation.DelegatingWsConfiguration$$EnhancerBySpringCGLIB$$b4635f5c] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
    2018-11-21 22:08:17.247  INFO 3913 --- [  restartedMain] .w.s.a.s.AnnotationActionEndpointMapping : Supporting [WS-Addressing August 2004, WS-Addressing 1.0]
    2018-11-21 22:08:17.414  INFO 3913 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean ' org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [ org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$fcb9a5d] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
    2018-11-21 22:08:17.654  INFO 3913 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.hateoas.config.HateoasConfiguration' of type [ org.springframework.hateoas.config.HateoasConfiguration$$EnhancerBySpringCGLIB$$8f4be78f] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
    2018-11-21 22:08:18.783  INFO 3913 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
    2018-11-21 22:08:18.849  INFO 3913 --- [  restartedMain] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
    2018-11-21 22:08:18.850  INFO 3913 --- [  restartedMain] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.34
    2018-11-21 22:08:18.876  INFO 3913 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener   : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib]
    2018-11-21 22:08:19.099  INFO 3913 --- [ost-startStop-1] o.a.c.c.C.[Tomcat]. [localhost]. [/]       : Initializing Spring embedded WebApplicationContext
    2018-11-21 22:08:19.103  INFO 3913 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 7315 ms
    2018-11-21 22:08:20.203  INFO 3913 --- [ost-startStop-1] o.s.j.d.DriverManagerDataSource          : Loaded JDBC driver: org.h2.Driver
    2018-11-21 22:08:20.823  INFO 3913 --- [ost-startStop-1] o.s.s.web.DefaultSecurityFilterChain     : Creating filter chain: Ant [pattern='/resources/**'], []
    2018-11-21 22:08:21.100  INFO 3913 --- [ost-startStop-1] o.s.s.p.JdbcUserDetailsManager           : No authentication manager set. Reauthentication of users when changing passwords will not be performed.
    2018-11-21 22:08:21.370  INFO 3913 --- [ost-startStop-1] o.s.s.web.DefaultSecurityFilterChain     : Creating filter chain: org.springframework.security.web.util.matcher.AnyRequestMatcher@1, [org.springframework.security.web.context.SecurityContextPersistenceFilter@4294627f, org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@21e157ed, org.springframework.security.web.header.HeaderWriterFilter@5d3d9f8c, org.springframework.security.web.csrf.CsrfFilter@309333e8, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter@3f7bf900, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@485ec9d3, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter @236ad6b2, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@140fa9fd, org.springframework.security.web.session.SessionManagementFilter @2e3d5d68, org.springframework.security.web.access.ExceptionTranslationFilter@321ea81f, org.springframework.security.web.access.intercept.FilterSecurityInterceptor @3cb8af30]
    2018-11-21 22:08:21.398  INFO 3913 --- [ost-startStop-1] o.s.s.c.h.DefaultFilterChainValidator    : Checking whether login URL '/login' is accessible with your configuration
    2018-11-21 22:08:21.578  INFO 3913 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: ' org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0' to: [/*]
    2018-11-21 22:08:21.578  INFO 3913 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Servlet dispatcherServlet mapped to [/]
    2018-11-21 22:08:21.580  INFO 3913 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Servlet webServlet mapped to [/h2-console/*]
    2018-11-21 22:08:21.581  INFO 3913 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Servlet messageDispatcherServlet mapped to [/services/*]
    2018-11-21 22:08:21.969  INFO 3913 --- [  restartedMain] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
    2018-11-21 22:08:22.012  INFO 3913 --- [  restartedMain] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [
        name: default
        ...]
    2018-11-21 22:08:22.190  INFO 3913 --- [  restartedMain] org.hibernate.Version                    : HHH000412: Hibernate Core {5.2.17.Final}
    2018-11-21 22:08:22.194  INFO 3913 --- [  restartedMain] org.hibernate.cfg.Environment            : HHH000206: hibernate.properties not found
    2018-11-21 22:08:22.279  INFO 3913 --- [  restartedMain] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
    2018-11-21 22:08:22.691  INFO 3913 --- [  restartedMain] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
    2018-11-21 22:08:24.407  INFO 3913 --- [  restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
    2018-11-21 22:08:26.427  INFO 3913 --- [  restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
    2018-11-21 22:08:26.732  INFO 3913 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.web.servlet.context. AnnotationConfigServletWebServerApplicationContext@13fed3ea: startup date [Wed Nov 21 22:08:11 IST 2018]; root of context hierarchy
    2018-11-21 22:08:26.754  INFO 3913 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerAdapter : Detected @ModelAttribute methods in globalController
    2018-11-21 22:08:26.892  WARN 3913 --- [  restartedMain] aWebConfiguration$JpaWebMvcConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
    2018-11-21 22:08:27.152  INFO 3913 --- [  restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
    2018-11-21 22:08:27.197  INFO 3913 --- [  restartedMain] .m.m.a.ExceptionHandlerExceptionResolver : Detected @ExceptionHandler methods in globalDefaultExceptionHandler
    2018-11-21 22:08:27.198  INFO 3913 --- [  restartedMain] .m.m.a.ExceptionHandlerExceptionResolver : Detected @ExceptionHandler methods in repositoryRestExceptionHandler
    2018-11-21 22:08:28.114  INFO 3913 --- [  restartedMain] o.s.d.r.w.RepositoryRestHandlerAdapter   : Looking for @ControllerAdvice: org.springframework.boot.web.servlet.context. AnnotationConfigServletWebServerApplicationContext@13fed3ea: startup date [Wed Nov 21 22:08:11 IST 2018]; root of context hierarchy
    2018-11-21 22:08:28.123  INFO 3913 --- [  restartedMain] o.s.d.r.w.RepositoryRestHandlerAdapter   : Detected @ModelAttribute methods in globalController
    2018-11-21 22:08:28.146  INFO 3913 --- [  restartedMain] o.s.d.r.w.RepositoryRestHandlerMapping   : Mapped "{[/ || ],methods=[GET],produces=[application/hal+json || application/json]}" onto public org.springframework.http.HttpEntity<org.springframework.data.rest.webmvc.RepositoryLinksResource> org.springframework.data.rest.webmvc.RepositoryController.listRepositories()
    2018-11-21 22:08:28.319  INFO 3913 --- [  restartedMain] o.s.b.a.e.web.EndpointLinksResolver      : Exposing 2 endpoint(s) beneath base path '/actuator'
    2018-11-21 22:08:28.350  INFO 3913 --- [  restartedMain] s.b.a.e.w.s.WebMvcEndpointHandlerMapping : Mapped "{[/actuator],methods=[GET],produces=[application/ vnd.spring-boot.actuator.v2+json || application/json]}" onto protected java.util.Map<java.lang.String, java.util.Map<java.lang.String, org.springframework.boot.actuate.endpoint.web.Link>> org.springframework.boot.actuate.endpoint.web.servlet.WebMvcEndpointHandlerMapping.links(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
    2018-11-21 22:08:28.621  INFO 3913 --- [  restartedMain] o.s.b.d.a.OptionalLiveReloadServer       : LiveReload server is running on port 35729
    2018-11-21 22:08:28.784  INFO 3913 --- [  restartedMain] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
    2018-11-21 22:08:28.930  INFO 3913 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
    2018-11-21 22:08:28.956  INFO 3913 --- [  restartedMain] n.k.o.OnlineshoppingApplication          : Started OnlineshoppingApplication in 18.037 seconds (JVM running for 18.919)

My project file structure

enter image description here

enter image description here

Displays an error in the browser

enter image description here

Please tell me how to fix this. What am I doing wrong here?

Solution

The answer is in documentation :

Do not use the src/main/webapp directory if your application is
packaged as a jar. Although this directory is a common standard, it
works only with war packaging, and it is silently ignored by most
build tools if you generate a jar.

Also:

By default, Spring Boot serves static content from a directory called
/static (or /public or /resources or /META-INF/resources) in the
classpath or from the root of the ServletContext

The options are:

  1. Move the contents of the src/main/webapp folder to the appropriate folder
  2. Add src/main/webapp to resources in pom.xml
  3. Use war wrapping

Finally, check if you still have the correct path in your configuration file.

Related Problems and Solutions