2014-04-25 9 views
11

Ho sviluppato con successo un prototipo utilizzando Spring Boot 1.0.2.RELEASE (era 1.0.1.RELEASE fino ad oggi).L'avvio di primavera non riesce a caricare DataSource utilizzando il driver PostgreSQL

ho cercato e cercato e cercato soluzioni come: Spring Boot jdbc datasource autoconfiguration fails on standalone tomcat Spring Boot/Spring Data import.sql doesn't run Spring-Boot-1.0.0.RC1

Tutti suggerisce di lasciar primavera avvio fare il lavoro. Quando si utilizza H2, tutto funziona, ma quando provo a passare a PostgreSQL, ottengo:

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 

mio build.gradle è la seguente:

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' 
} 

application.properties:

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 

Rimozione di application.properties e modifica della dipendenza in H2 e tutto è OK.

non riesco a trovare dove sto facendo male :-(

risposta

16

Dove si è arrivati ​​da:? database.driverClassName=org.postgresql.Driver Non intendi spring.datasource.driverClassName

+0

Assolutamente Copy-n-paste errore di battitura domanda aggiornato?.! Grazie! – mamruoc

+0

CHE UN ERRORE DI TYPO! Ok, origine dati e non database * sospiro * – mamruoc

Problemi correlati