相关疑难解决方法(0)

数据源的Spring Boot自动配置

我尝试使用Hibernate 5和Postgres 9创建Spring Boot应用程序.现在我有下一个错误:

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
Run Code Online (Sandbox Code Playgroud)

虽然,我添加了spring.datasource.*属性:

spring.datasource.url=jdbc:postgresql://localhost:5432/postgres
spring.datasource.username=postgres
spring.datasource.password=root
Run Code Online (Sandbox Code Playgroud)

我的pom.xml:

<properties>
    <hibernate.version>5.2.6.Final</hibernate.version>
    <spring.data.version>1.10.6.RELEASE</spring.data.version>
</properties>

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

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-autoconfigure</artifactId>
    </dependency>

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

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>${spring.version}</version>
    </dependency> …
Run Code Online (Sandbox Code Playgroud)

java hibernate maven spring-boot

26
推荐指数
2
解决办法
8万
查看次数

标签 统计

hibernate ×1

java ×1

maven ×1

spring-boot ×1