title: Spring Security - No qualifying bean of type 'javax.sql.DataSource' available: expected at least 1 bean which qualifies as autowire candidate
body: <p>I am trying to repeat from the Spring Security documentation and trying to protect one web page as a test. I do everything strictly according to the documentation as the spring writes.</p>
  
  <p><a href="https://docs.spring.io/spring-security/site/docs/5.2.2.RELEASE/reference/htmlsingle/#jc-authentication-jdbc" rel="nofollow noreferrer">Spring Documentation - 1</a><br />
  <a href="https://docs.spring.io/spring-security/site/docs/current/reference/html/jc.html#abstractsecuritywebapplicationinitializer-with-spring-mvc" rel="nofollow noreferrer">Spring Documentation - 2</a><br />
  <a href="https://docs.spring.io/spring-security/site/docs/current/reference/html5/#mvc" rel="nofollow noreferrer">Spring Documentation - 3</a></p>
  
  <p>But it does not work. I have been tormented by this issue for 7 days. I'm going crazy.
  I do not know what to do with this and how to overcome this mistake. It occurs at the assembly stage of the project.
  Who can help please.
  <br /><br />
  <b>Here is error log:</b></p>
  
  <pre>C:\TomCat\apache-tomcat-9.0.30\bin\catalina.bat run
  [2020-02-22 12:42:59,722] Artifact ConcretePage:war exploded: Waiting for server connection to start artifact deployment...
  Using CATALINA_BASE:   "C:\Users\ѓҐ­­ ¤Ё©\.IntelliJIdea2019.3\system\tomcat\Unnamed_ConcretePage_2"
  Using CATALINA_HOME:   "C:\TomCat\apache-tomcat-9.0.30"
  Using CATALINA_TMPDIR: "C:\TomCat\apache-tomcat-9.0.30\temp"
  Using JRE_HOME:        "C:\Program Files\Java\jdk1.8.0_241"
  Using CLASSPATH:       "C:\TomCat\apache-tomcat-9.0.30\bin\bootstrap.jar;C:\TomCat\apache-tomcat-9.0.30\bin\tomcat-juli.jar"
  22-Feb-2020 00:43:01.416 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version name:   Apache Tomcat/9.0.30
  22-Feb-2020 00:43:01.418 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built:          Dec 7 2019 16:42:04 UTC
  22-Feb-2020 00:43:01.418 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version number: 9.0.30.0
  22-Feb-2020 00:43:01.419 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name:               Windows 10
  22-Feb-2020 00:43:01.419 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version:            10.0
  22-Feb-2020 00:43:01.419 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture:          amd64
  22-Feb-2020 00:43:01.419 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home:             C:\Program Files\Java\jdk1.8.0_241\jre
  22-Feb-2020 00:43:01.419 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version:           1.8.0_241-b07
  22-Feb-2020 00:43:01.419 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor:            Oracle Corporation
  22-Feb-2020 00:43:01.419 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE:         C:\Users\Р“РµРЅРЅР°РґРёР№\.IntelliJIdea2019.3\system\tomcat\Unnamed_ConcretePage_2
  22-Feb-2020 00:43:01.420 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME:         C:\TomCat\apache-tomcat-9.0.30
  22-Feb-2020 00:43:01.420 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=C:\Users\Р“РµРЅРЅР°РґРёР№\.IntelliJIdea2019.3\system\tomcat\Unnamed_ConcretePage_2\conf\logging.properties
  22-Feb-2020 00:43:01.421 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
  22-Feb-2020 00:43:01.421 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote=
  22-Feb-2020 00:43:01.421 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.port=1099
  22-Feb-2020 00:43:01.421 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.ssl=false
  22-Feb-2020 00:43:01.422 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.password.file=C:\Users\Р“РµРЅРЅР°РґРёР№\.IntelliJIdea2019.3\system\tomcat\Unnamed_ConcretePage_2\jmxremote.password
  22-Feb-2020 00:43:01.422 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.access.file=C:\Users\Р“РµРЅРЅР°РґРёР№\.IntelliJIdea2019.3\system\tomcat\Unnamed_ConcretePage_2\jmxremote.access
  22-Feb-2020 00:43:01.422 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.rmi.server.hostname=127.0.0.1
  22-Feb-2020 00:43:01.422 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
  22-Feb-2020 00:43:01.423 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
  22-Feb-2020 00:43:01.423 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dignore.endorsed.dirs=
  22-Feb-2020 00:43:01.423 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=C:\Users\Р“РµРЅРЅР°РґРёР№\.IntelliJIdea2019.3\system\tomcat\Unnamed_ConcretePage_2
  22-Feb-2020 00:43:01.423 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=C:\TomCat\apache-tomcat-9.0.30
  22-Feb-2020 00:43:01.424 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=C:\TomCat\apache-tomcat-9.0.30\temp
  22-Feb-2020 00:43:01.424 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded APR based Apache Tomcat Native library [1.2.23] using APR version [1.7.0].
  22-Feb-2020 00:43:01.424 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
  22-Feb-2020 00:43:01.424 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
  22-Feb-2020 00:43:01.432 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized [OpenSSL 1.1.1c  28 May 2019]
  22-Feb-2020 00:43:01.878 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
  22-Feb-2020 00:43:01.928 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"]
  22-Feb-2020 00:43:01.934 INFO [main] org.apache.catalina.startup.Catalina.load Server initialization in [840] milliseconds
  22-Feb-2020 00:43:01.984 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
  22-Feb-2020 00:43:01.985 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet engine: [Apache Tomcat/9.0.30]
  22-Feb-2020 00:43:02.003 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
  22-Feb-2020 00:43:02.017 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]
  22-Feb-2020 00:43:02.022 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in [86] milliseconds
  Connected to server
  [2020-02-22 12:43:02,357] Artifact ConcretePage:war exploded: Artifact is being deployed, please wait...
  22-Feb-2020 00:43:06.552 INFO [RMI TCP Connection(3)-127.0.0.1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
  22-Feb-2020 00:43:06.592 INFO [RMI TCP Connection(3)-127.0.0.1] org.springframework.web.context.ContextLoader.initWebApplicationContext Root WebApplicationContext: initialization started
  22-Feb-2020 00:43:07.807 WARNING [RMI TCP Connection(3)-127.0.0.1] org.springframework.context.support.AbstractApplicationContext.refresh Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'webSecurityConfig': Unsatisfied dependency expressed through field 'dataSource'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'javax.sql.DataSource' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
  22-Feb-2020 00:43:07.818 SEVERE [RMI TCP Connection(3)-127.0.0.1] org.springframework.web.context.ContextLoader.initWebApplicationContext Context initialization failed
      org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'webSecurityConfig': Unsatisfied dependency expressed through field 'dataSource'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'javax.sql.DataSource' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
          at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:643)
          at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:116)
          at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1422)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517)
          at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323)
          at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
          at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321)
          at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
          at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:879)
          at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:878)
          at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550)
          at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:401)
          at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:292)
          at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:103)
          at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4683)
          at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5146)
          at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
          at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:717)
          at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:690)
          at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:705)
          at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1728)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:498)
          at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:289)
          at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
          at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
          at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:456)
          at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:405)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:498)
          at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:289)
          at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
          at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
          at com.sun.jmx.remote.security.MBeanServerAccessController.invoke(MBeanServerAccessController.java:468)
          at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1468)
  [2020-02-22 12:43:07,866] Artifact ConcretePage:war exploded: Error during artifact deployment. See server log for details.
          at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76)
          at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1309)
          at java.security.AccessController.doPrivileged(Native Method)
          at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1408)
          at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:829)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:498)
          at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:357)
          at sun.rmi.transport.Transport$1.run(Transport.java:200)
          at sun.rmi.transport.Transport$1.run(Transport.java:197)
          at java.security.AccessController.doPrivileged(Native Method)
          at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
          at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:573)
          at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:834)
          at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:688)
          at java.security.AccessController.doPrivileged(Native Method)
          at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:687)
          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
          at java.lang.Thread.run(Thread.java:748)
      Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'javax.sql.DataSource' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
          at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1695)
          at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1253)
          at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1207)
          at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:640)
          ... 62 more
  22-Feb-2020 00:43:07.828 SEVERE [RMI TCP Connection(3)-127.0.0.1] org.apache.catalina.core.StandardContext.startInternal One or more listeners failed to start. Full details will be found in the appropriate container log file
  22-Feb-2020 00:43:07.834 SEVERE [RMI TCP Connection(3)-127.0.0.1] org.apache.catalina.core.StandardContext.startInternal Context [] startup failed due to previous errors
  22-Feb-2020 00:43:12.010 INFO [Catalina-utility-2] org.apache.catalina.startup.HostConfig.deployDirectory РЈСЃС‚Р°РЅРѕРІРєР° РІРµР± РїСЂРёР»РѕР¶РµРЅРёСЏ РІ РїР°РїРєСѓ [C:\TomCat\apache-tomcat-9.0.30\webapps\manager]
  22-Feb-2020 00:43:12.209 INFO [Catalina-utility-2] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\TomCat\apache-tomcat-9.0.30\webapps\manager] has finished in [199] ms
  </pre>
  
  <p><br /><br />
  <b>Below is my project</b><br /><br /></p>
  
  <p><strong>package</strong> com.concretepage.<strong>config</strong>;</p>
  
  <p><strong>FreeMarkerConfig.class</strong></p>
  
  <p><pre>
      package com.concretepage.config;</p>
  
  <pre><code>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.view.freemarker.FreeMarkerConfigurer;
  import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver;
  
  @Configuration
  @ComponentScan({"com.concretepage"})
  public class FreeMarkerConfig {
  
      @Bean
      public FreeMarkerConfigurer freeMarkerConfigurer() {
          FreeMarkerConfigurer configurer = new FreeMarkerConfigurer();
          configurer.setTemplateLoaderPath("/WEB-INF/templates");
          configurer.setDefaultEncoding("UTF-8");
          return configurer;
      }
  
      @Bean
      public ViewResolver getViewResolver(){
          FreeMarkerViewResolver viewResolver = new FreeMarkerViewResolver();
          viewResolver.setSuffix(".ftl");
          viewResolver.setContentType("text/html;charset=UTF-8");
          viewResolver.setCache(false);
          return viewResolver;
      }
  }
  </code></pre>
  
  <p></pre><br /></p>
  
  <p><b>MessageWebApplicationInitializer.class</b><br /><br /></p>
  
  <p><pre>
      package com.concretepage.config;</p>
  
  <pre><code>import com.concretepage.security.WebSecurityConfig;
  import org.springframework.core.annotation.Order;
  import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
  
  @Order(1)
  public class MessageWebApplicationInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
  
      @Override
      protected Class&lt;?&gt;[] getRootConfigClasses() {
          return new Class&lt;?&gt;[]{ WebSecurityConfig.class };
      }
  
      @Override
      protected Class&lt;?&gt;[] getServletConfigClasses() {
          return new Class&lt;?&gt;[]{ SQLConfig.class, FreeMarkerConfig.class };
      }
  
      @Override
      protected String[] getServletMappings() {
          return new String[] { "/" };
      }
  
  }
  </code></pre>
  
  <p></pre><br /></p>
  
  <p><b>SQLConfig.class</b><br /></p>
  
  <p><pre>
      package com.concretepage.config;</p>
  
  <pre><code>import org.springframework.context.annotation.Bean;
  import org.springframework.context.annotation.ComponentScan;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.jdbc.datasource.DriverManagerDataSource;
  
  import javax.sql.DataSource;
  
  @Configuration
  @ComponentScan("com.concretepage.security")
  public class SQLConfig {
  
      public SQLConfig() {
      }
  
      @Bean
      public DataSource dataSource() {
          DriverManagerDataSource driverManagerDataSource = new DriverManagerDataSource();
          driverManagerDataSource.setDriverClassName("com.mysql.cj.jdbc.Driver");
          driverManagerDataSource.setUrl("jdbc:mysql://localhost:3306/mysecurity?serverTimezone=UTC");
          driverManagerDataSource.setUsername("root");
          driverManagerDataSource.setPassword("1234");
          return driverManagerDataSource;
      }
  }
  </code></pre>
  
  <p></pre><br /><br /></p>
  
  <p><b>package</b> com.concretepage.<b>security</b>;</p>
  
  <p><b>SecurityWebApplicationInitializer.class</b></p>
  
  <p><pre>
      package com.concretepage.security;</p>
  
  <pre><code>import org.springframework.core.annotation.Order;
  import org.springframework.security.web.context.AbstractSecurityWebApplicationInitializer;
  
  @Order(2)
  public class SecurityWebApplicationInitializer extends AbstractSecurityWebApplicationInitializer {
  
  }
  </code></pre>
  
  <p></pre><br /></p>
  
  <p><b>WebSecurityConfig.class</b><br /></p>
  
  <p><pre>
      package com.concretepage.security;</p>
  
  <pre><code>import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
  import org.springframework.security.config.annotation.web.configuration.*;
  import org.springframework.security.core.userdetails.User;
  
  import javax.sql.DataSource;
  
  
  @EnableWebSecurity
  public class WebSecurityConfig {
  
      @Autowired
      public DataSource dataSource;
  
      @Autowired
      public void configure(AuthenticationManagerBuilder auth) throws Exception {
          // ensure the passwords are encoded properly
          User.UserBuilder user = User.builder();
          auth
                  .jdbcAuthentication()
                  .dataSource(dataSource)
                  .withDefaultSchema()
                  .withUser(user.username("user").password("{noop}password").roles("USER"))
                  .withUser(user.username("admin").password("{noop}password").roles("USER","ADMIN"));
      }
  }
  </code></pre>
  
  <p></pre><br /><br /></p>
  
  <p><b>package</b> com.<b>concretepage</b>;</p>
  
  <p><b>HomeController.class</b></p>
  
  <p><pre>
      package com.concretepage;</p>
  
  <pre><code>import org.springframework.stereotype.Controller;
  import org.springframework.web.bind.annotation.GetMapping;
  
  @Controller
  public class HomeController {
  
      @GetMapping("/")
      public String home () {
          return "/home";
      }
  
      @GetMapping("/login")
      public String login () {
          return "/login";
      }
  
  }
  </code></pre>
  
  <p></pre><br /><br /><br />
  <b>POM.xml</b><br /><br /></p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &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.concretepage&lt;/groupId&gt;
      &lt;artifactId&gt;ConcretePage&lt;/artifactId&gt;
      &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
  
      &lt;build&gt;
          &lt;plugins&gt;
  
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                  &lt;version&gt;3.8.1&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;source&gt;${java.version}&lt;/source&gt;
                      &lt;target&gt;${java.version}&lt;/target&gt;
                      &lt;encoding&gt;${encoding}&lt;/encoding&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
  
          &lt;/plugins&gt;
      &lt;/build&gt;
  
      &lt;properties&gt;
          &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
          &lt;failOnMissingWebXml&gt;false&lt;/failOnMissingWebXml&gt;
          &lt;java.version&gt;1.8&lt;/java.version&gt;
          &lt;encoding&gt;UTF-8&lt;/encoding&gt;
      &lt;/properties&gt;
  
      &lt;dependencyManagement&gt;
          &lt;dependencies&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.springframework&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-framework-bom&lt;/artifactId&gt;
                  &lt;version&gt;5.2.3.RELEASE&lt;/version&gt;
                  &lt;type&gt;pom&lt;/type&gt;
                  &lt;scope&gt;import&lt;/scope&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-security-bom&lt;/artifactId&gt;
                  &lt;version&gt;5.2.2.RELEASE&lt;/version&gt;
                  &lt;type&gt;pom&lt;/type&gt;
                  &lt;scope&gt;import&lt;/scope&gt;
              &lt;/dependency&gt;
          &lt;/dependencies&gt;
      &lt;/dependencyManagement&gt;
  
  
      &lt;dependencies&gt;
  
  &lt;!--        Spring Security--&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
              &lt;artifactId&gt;spring-security-core&lt;/artifactId&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
              &lt;artifactId&gt;spring-security-web&lt;/artifactId&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
              &lt;artifactId&gt;spring-security-config&lt;/artifactId&gt;
          &lt;/dependency&gt;
  
  
  
  &lt;!--        Spring Framework--&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-jdbc&lt;/artifactId&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-webmvc&lt;/artifactId&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-context-support&lt;/artifactId&gt;
          &lt;/dependency&gt;
  
  
  
          &lt;dependency&gt;
              &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
              &lt;artifactId&gt;javax.servlet-api&lt;/artifactId&gt;
              &lt;version&gt;4.0.1&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;mysql&lt;/groupId&gt;
              &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
              &lt;version&gt;8.0.19&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.freemarker&lt;/groupId&gt;
              &lt;artifactId&gt;freemarker&lt;/artifactId&gt;
              &lt;version&gt;2.3.29&lt;/version&gt;
          &lt;/dependency&gt;
  
      &lt;/dependencies&gt;
  
  &lt;/project&gt;
  </code></pre>