Application with Spring Boot does not rise - org.springframework.beans.factory.UnsatisfiedDependencyException

1

I created the application from SPRING INITIALIZR. I made the adjustments for the first operation and configured the application.properties however I still receive the same exception:

2017-05-24 16:49:23.784  WARN 5568 --- [           main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration': Unsatisfied dependency expressed through constructor parameter 0; 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: {}
2017-05-24 16:49:23.786  INFO 5568 --- [           main] o.apache.catalina.core.StandardService   : Stopping service Tomcat
2017-05-24 16:49:23.794  WARN 5568 --- [           main] o.s.boot.SpringApplication               : Error handling failed (Error creating bean with name 'delegatingApplicationListener' defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration': Initialization of bean failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'org.springframework.context.annotation.ConfigurationClassPostProcessor.importRegistry' available)
2017-05-24 16:49:23.854 ERROR 5568 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

All content printed on the console:

"C:\Program Files\Java\jdk1.8.0_131\bin\java" -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2017.1.2\lib\idea_rt.jar=61573:C:\Program Files\JetBrains\IntelliJ IDEA 2017.1.2\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\jdk1.8.0_131\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\rt.jar;E:\Projetos\Projetos Java\exuberance-api\target\classes;C:\Users\Calebe Machado\.m2\repository\org\springframework\boot\spring-boot-starter-web.5.2.RELEASE\spring-boot-starter-web-1.5.2.RELEASE.jar;C:\Users\Calebe Machado\.m2\repository\org\springframework\boot\spring-boot-starter.5.2.RELEASE\spring-boot-starter-1.5.2.RELEASE.jar;C:\Users\Calebe Machado\.m2\repository\org\springframework\boot\spring-boot.5.2.RELEASE\spring-boot-1.5.2.RELEASE.jar;C:\Users\Calebe Machado\.m2\repository\org\springframework\boot\spring-boot-autoconfigure.5.2.RELEASE\spring-boot-autoconfigure-1.5.2.RELEASE.jar;C:\Users\Calebe Machado\.m2\repository\org\springframework\boot\spring-boot-starter-logging.5.2.RELEASE\spring-boot-starter-logging-1.5.2.RELEASE.jar;C:\Users\Calebe Machado\.m2\repository\ch\qos\logback\logback-classic.1.11\logback-classic-1.1.11.jar;C:\Users\Calebe Machado\.m2\repository\ch\qos\logback\logback-core.1.11\logback-core-1.1.11.jar;C:\Users\Calebe Machado\.m2\repository\org\slf4j\jul-to-slf4j.7.24\jul-to-slf4j-1.7.24.jar;C:\Users\Calebe Machado\.m2\repository\org\slf4j\log4j-over-slf4j.7.24\log4j-over-slf4j-1.7.24.jar;C:\Users\Calebe Machado\.m2\repository\org\yaml\snakeyaml.17\snakeyaml-1.17.jar;C:\Users\Calebe Machado\.m2\repository\org\springframework\boot\spring-boot-starter-tomcat.5.2.RELEASE\spring-boot-starter-tomcat-1.5.2.RELEASE.jar;C:\Users\Calebe Machado\.m2\repository\org\apache\tomcat\embed\tomcat-embed-core.5.11\tomcat-embed-core-8.5.11.jar;C:\Users\Calebe Machado\.m2\repository\org\apache\tomcat\embed\tomcat-embed-el.5.11\tomcat-embed-el-8.5.11.jar;C:\Users\Calebe Machado\.m2\repository\org\apache\tomcat\embed\tomcat-embed-websocket.5.11\tomcat-embed-websocket-8.5.11.jar;C:\Users\Calebe Machado\.m2\repository\org\hibernate\hibernate-validator.3.4.Final\hibernate-validator-5.3.4.Final.jar;C:\Users\Calebe Machado\.m2\repository\javax\validation\validation-api.1.0.Final\validation-api-1.1.0.Final.jar;C:\Users\Calebe Machado\.m2\repository\org\jboss\logging\jboss-logging.3.0.Final\jboss-logging-3.3.0.Final.jar;C:\Users\Calebe Machado\.m2\repository\com\fasterxml\classmate.3.3\classmate-1.3.3.jar;C:\Users\Calebe Machado\.m2\repository\com\fasterxml\jackson\core\jackson-databind.8.7\jackson-databind-2.8.7.jar;C:\Users\Calebe Machado\.m2\repository\com\fasterxml\jackson\core\jackson-annotations.8.0\jackson-annotations-2.8.0.jar;C:\Users\Calebe Machado\.m2\repository\com\fasterxml\jackson\core\jackson-core.8.7\jackson-core-2.8.7.jar;C:\Users\Calebe Machado\.m2\repository\org\springframework\spring-web.3.7.RELEASE\spring-web-4.3.7.RELEASE.jar;C:\Users\Calebe Machado\.m2\repository\org\springframework\spring-webmvc.3.7.RELEASE\spring-webmvc-4.3.7.RELEASE.jar;C:\Users\Calebe Machado\.m2\repository\org\springframework\spring-expression.3.7.RELEASE\spring-expression-4.3.7.RELEASE.jar;C:\Users\Calebe Machado\.m2\repository\org\springframework\boot\spring-boot-starter-data-jpa.5.2.RELEASE\spring-boot-starter-data-jpa-1.5.2.RELEASE.jar;C:\Users\Calebe Machado\.m2\repository\org\springframework\boot\spring-boot-starter-aop.5.2.RELEASE\spring-boot-starter-aop-1.5.2.RELEASE.jar;C:\Users\Calebe Machado\.m2\repository\org\aspectj\aspectjweaver.8.9\aspectjweaver-1.8.9.jar;C:\Users\Calebe Machado\.m2\repository\org\springframework\boot\spring-boot-starter-jdbc.5.2.RELEASE\spring-boot-starter-jdbc-1.5.2.RELEASE.jar;C:\Users\Calebe Machado\.m2\repository\org\springframework\spring-jdbc.3.7.RELEASE\spring-jdbc-4.3.7.RELEASE.jar;C:\Users\Calebe Machado\.m2\repository\org\hibernate\hibernate-core.0.12.Final\hibernate-core-5.0.12.Final.jar;C:\Users\Calebe Machado\.m2\repository\org\hibernate\javax\persistence\hibernate-jpa-2.1-api.0.0.Final\hibernate-jpa-2.1-api-1.0.0.Final.jar;C:\Users\Calebe Machado\.m2\repository\org\javassist\javassist.21.0-GA\javassist-3.21.0-GA.jar;C:\Users\Calebe Machado\.m2\repository\antlr\antlr.7.7\antlr-2.7.7.jar;C:\Users\Calebe Machado\.m2\repository\org\jboss\jandex.0.0.Final\jandex-2.0.0.Final.jar;C:\Users\Calebe Machado\.m2\repository\dom4j\dom4j.6.1\dom4j-1.6.1.jar;C:\Users\Calebe Machado\.m2\repository\org\hibernate\common\hibernate-commons-annotations.0.1.Final\hibernate-commons-annotations-5.0.1.Final.jar;C:\Users\Calebe Machado\.m2\repository\org\hibernate\hibernate-entitymanager.0.12.Final\hibernate-entitymanager-5.0.12.Final.jar;C:\Users\Calebe Machado\.m2\repository\javax\transaction\javax.transaction-api.2\javax.transaction-api-1.2.jar;C:\Users\Calebe Machado\.m2\repository\org\springframework\data\spring-data-jpa.11.1.RELEASE\spring-data-jpa-1.11.1.RELEASE.jar;C:\Users\Calebe Machado\.m2\repository\org\springframework\data\spring-data-commons.13.1.RELEASE\spring-data-commons-1.13.1.RELEASE.jar;C:\Users\Calebe Machado\.m2\repository\org\springframework\spring-orm.3.7.RELEASE\spring-orm-4.3.7.RELEASE.jar;C:\Users\Calebe Machado\.m2\repository\org\springframework\spring-tx.3.7.RELEASE\spring-tx-4.3.7.RELEASE.jar;C:\Users\Calebe Machado\.m2\repository\org\slf4j\slf4j-api.7.24\slf4j-api-1.7.24.jar;C:\Users\Calebe Machado\.m2\repository\org\slf4j\jcl-over-slf4j.7.24\jcl-over-slf4j-1.7.24.jar;C:\Users\Calebe Machado\.m2\repository\org\springframework\spring-aspects.3.7.RELEASE\spring-aspects-4.3.7.RELEASE.jar;C:\Users\Calebe Machado\.m2\repository\org\springframework\boot\spring-boot-starter-security.5.2.RELEASE\spring-boot-starter-security-1.5.2.RELEASE.jar;C:\Users\Calebe Machado\.m2\repository\org\springframework\spring-aop.3.7.RELEASE\spring-aop-4.3.7.RELEASE.jar;C:\Users\Calebe Machado\.m2\repository\org\springframework\security\spring-security-config.2.2.RELEASE\spring-security-config-4.2.2.RELEASE.jar;C:\Users\Calebe Machado\.m2\repository\org\springframework\security\spring-security-web.2.2.RELEASE\spring-security-web-4.2.2.RELEASE.jar;C:\Users\Calebe Machado\.m2\repository\org\springframework\security\oauth\spring-security-oauth2.0.13.RELEASE\spring-security-oauth2-2.0.13.RELEASE.jar;C:\Users\Calebe Machado\.m2\repository\org\springframework\spring-beans.3.7.RELEASE\spring-beans-4.3.7.RELEASE.jar;C:\Users\Calebe Machado\.m2\repository\org\springframework\spring-core.3.7.RELEASE\spring-core-4.3.7.RELEASE.jar;C:\Users\Calebe Machado\.m2\repository\org\springframework\spring-context.3.7.RELEASE\spring-context-4.3.7.RELEASE.jar;C:\Users\Calebe Machado\.m2\repository\org\springframework\security\spring-security-core.2.2.RELEASE\spring-security-core-4.2.2.RELEASE.jar;C:\Users\Calebe Machado\.m2\repository\aopalliance\aopalliance.0\aopalliance-1.0.jar;C:\Users\Calebe Machado\.m2\repository\commons-codec\commons-codec.10\commons-codec-1.10.jar;C:\Users\Calebe Machado\.m2\repository\org\codehaus\jackson\jackson-mapper-asl.9.13\jackson-mapper-asl-1.9.13.jar;C:\Users\Calebe Machado\.m2\repository\org\codehaus\jackson\jackson-core-asl.9.13\jackson-core-asl-1.9.13.jar;C:\Users\Calebe Machado\.m2\repository\org\postgresql\postgresql.4-1206-jdbc42\postgresql-9.4-1206-jdbc42.jar" br.com.calebe.exuberance.Main

  .   ____          _            __ _ _
 /\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _' | \ \ \ \
 \/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.5.2.RELEASE)

2017-05-24 16:49:22.594  INFO 5568 --- [           main] br.com.calebe.exuberance.Main            : Starting Main on DESKTOP-94T74A9 with PID 5568 (started by Calebe Machado in E:\Projetos\Projetos Java\exuberance-api)
2017-05-24 16:49:22.594  INFO 5568 --- [           main] br.com.calebe.exuberance.Main            : No active profile set, falling back to default profiles: default
2017-05-24 16:49:22.625  INFO 5568 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@fe18270: startup date [Wed May 24 16:49:22 BRT 2017]; root of context hierarchy
2017-05-24 16:49:23.415  INFO 5568 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$c5e426ec] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-05-24 16:49:23.614  INFO 5568 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2017-05-24 16:49:23.620  INFO 5568 --- [           main] o.apache.catalina.core.StandardService   : Starting service Tomcat
2017-05-24 16:49:23.621  INFO 5568 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.11
2017-05-24 16:49:23.672  INFO 5568 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2017-05-24 16:49:23.672  INFO 5568 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 1047 ms
2017-05-24 16:49:23.768  INFO 5568 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2017-05-24 16:49:23.769  INFO 5568 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2017-05-24 16:49:23.769  INFO 5568 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2017-05-24 16:49:23.769  INFO 5568 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2017-05-24 16:49:23.769  INFO 5568 --- [ost-startStop-1] .s.DelegatingFilterProxyRegistrationBean : Mapping filter: 'springSecurityFilterChain' to: [/*]
2017-05-24 16:49:23.769  INFO 5568 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: 'dispatcherServlet' to [/]
2017-05-24 16:49:23.784  WARN 5568 --- [           main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration': Unsatisfied dependency expressed through constructor parameter 0; 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: {}
2017-05-24 16:49:23.786  INFO 5568 --- [           main] o.apache.catalina.core.StandardService   : Stopping service Tomcat
2017-05-24 16:49:23.794  WARN 5568 --- [           main] o.s.boot.SpringApplication               : Error handling failed (Error creating bean with name 'delegatingApplicationListener' defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration': Initialization of bean failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'org.springframework.context.annotation.ConfigurationClassPostProcessor.importRegistry' available)
2017-05-24 16:49:23.854 ERROR 5568 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

Parameter 0 of constructor in org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration required a bean of type 'javax.sql.DataSource' that could not be found.
    - Bean method 'dataSource' not loaded because @ConditionalOnProperty (spring.datasource.jndi-name) did not find property 'jndi-name'
    - Bean method 'dataSource' not loaded because @ConditionalOnBean (types: org.springframework.boot.jta.XADataSourceWrapper; SearchStrategy: all) did not find any beans


Action:

Consider revisiting the conditions above or defining a bean of type 'javax.sql.DataSource' in your configuration.


Process finished with exit code 1

application.properties:

spring.datasource.url=jdbc:postgresql://localhost:5432/exuberance
spring.datasource.username=postgres
spring.datasource.password=admin
spring.datasource.driver-class-name=org.postgresql.Driver

spring.jpa.database=POSTGRESQL
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update

Spring Application Main:

package br.com.calebe.exuberance;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class Main {

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

HomeController:

package br.com.calebe.exuberance.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HomeController {

    @RequestMapping(value = "/", method = RequestMethod.GET)
    public String home() {
        return "Hello";
    }

    @RequestMapping(value = "/private", method = RequestMethod.GET)
    public String privateArea() {
        return "Private";
    }
}

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>br.com.calebe</groupId>
    <artifactId>exuberance-backend</artifactId>
    <version>1.0-SNAPSHOT</version>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.2.RELEASE</version>
    </parent>

    <dependencies>
        <!-- Add typical dependencies for a web application -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <!-- Add JPA support -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.tomcat</groupId>
                    <artifactId>tomcat-jdbc</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <!-- Add Spring Security support -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.security.oauth</groupId>
            <artifactId>spring-security-oauth2</artifactId>
        </dependency>
        <!-- Add PostgreSQL database support [for running with PRODUCTION profile] -->
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>9.4-1206-jdbc42</version>
        </dependency>
    </dependencies>

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

    <build>
        <plugins>
            <plugin>
                <!-- Include if you want to make an executable jar[FAT JAR which
                includes all dependencies along with springboot loader] that you
                can run on commandline using java -jar NAME -->
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>

EDIT 1 - I noticed that the problem happens if I extend the CrudRepository or the Spring JpaRepository in my repository interface. In the case of implementing using the DataSource injected with @Autowired, the problem does not occur. Once I get the job put my repository interface.

    
asked by anonymous 24.05.2017 / 22:14