我已经成功地使用Spring Boot 1.0.2开发了一个原型.发布(直到今天才发布1.0.1版本).

I have searched and searched and tried solutions like: Spring Boot jdbc datasource autoconfiguration fails on standalone tomcat Spring Boot / Spring Data import.sql doesn't run Spring-Boot-1.0.0.RC1

他们都建议让Spring Boot来完成这项工作.

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration.entityManagerFactory(org.springframework.orm.jpa.JpaVendorAdapter)] threw exception; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [javax.sql.DataSource] is defined

我的身材.gradle如下所示:

loadConfiguration()

def loadConfiguration() {
def environment = hasProperty('env') ? env : 'dev'
project.ext.envrionment = environment
println "Environment is set to $environment"

def configFile = file('config.groovy')
def config = new ConfigSlurper("$environment").parse(configFile.toURL())
project.ext.config = config
}

buildscript {
ext {
    springBootVersion = '1.0.2.RELEASE'
}
repositories {
    mavenCentral()
}
dependencies {
    classpath("org.springframework.boot:spring-boot-gradle-   plugin:${springBootVersion}")
}
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'spring-boot'
apply plugin: 'war'
apply plugin: 'groovy'

war {
baseName = 'test'
version =  '0.0.1-SNAPSHOT'
}

configurations {
providedRuntime
}

repositories {
mavenCentral()
}

dependencies {
compile("org.springframework.boot:spring-boot-starter-web:${springBootVersion}")
compile("org.springframework.boot:spring-boot-starter-thymeleaf:${springBootVersion}")

compile("org.springframework.boot:spring-boot-starter-jdbc:${springBootVersion}")
compile("org.springframework.boot:spring-boot-starter-data-jpa:${springBootVersion}")
compile("postgresql:postgresql:9.1-901.jdbc4")
//compile("com.h2database:h2")

testCompile("org.springframework.boot:spring-boot-starter-test:${springBootVersion}")

}

task wrapper(type: Wrapper) {
gradleVersion = '1.11'
}

应用属性:

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

spring.database.driverClassName=org.postgresql.Driver
spring.datasource.url=jdbc:postgresql://localhost/cms
spring.datasource.username=cms
spring.datasource.password=NA

正在删除应用程序.属性,并将依赖关系更改回H2,一切正常.

我找不到我做错了什么:-(

推荐答案

这是从哪里来的:database.driverClassName=org.postgresql.Driver?你不是说spring.datasource.driverClassName吗?

Postgresql相关问答推荐

分区可以用于postgres中的同类查询吗?

一列引用两个不同的表

在Docker容器内的Postgres,如何通过Promail将JSON登录到Loki?

使用pg_repack从PostgreSQL中的表中删除OID

自左联接的POSTGIS更新

如何使用 Grafana 测量 PostgreSQL 中的复制

Postgres 将分区附加到表的时间太长.想明白为什么

将 postgres 从属提升为主 node

Django + Postgres + 大时间序列

如何在 Postgres 中的列上删除唯一约束?

带有 -C 选项的 pg_restore 不会创建数据库

如何使用 SpringBoot + JPA 存储 PostgreSQL jsonb?

在 PostgreSQL 中将时间转换为秒

如果 Column1 不为空,则按 Column1 排序,否则按 Column2 排序

如何防止materialized 视图在 pg_restore 期间刷新?

在 row_to_json 函数中 Select 查询

适配器 Ecto.Adapters.Postgres 未编译

错误:关系列不存在 PostgreSQL,无法运行插入查询

查询 JSON 列中的数组元素

如何在 PostgreSQL 中获取数组的最后一个元素?