Spring i Gradle problem z konfiguracją

Spring i Gradle problem z konfiguracją
IceHeart
  • Rejestracja: dni
  • Ostatnio: dni
  • Postów: 312
0

Witam,

stworzyłem sobie projekt Spring Boota i dodałem sobie jeszcze:
Spring Data, Spring Mvc, baze postgreSQL i mam problem przy uruchomieniu tomcata. Cały czas otrzymuje błąd:

Kopiuj
23:42:57.105 [http-nio-8080-exec-4] ERROR org.springframework.web.servlet.DispatcherServlet - Context initialization failed
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.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Tomcat.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.tomcat.jdbc.pool.DataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).
 

Szukałem na SO, niestety nic nie pomogło, wydaje mi się że coś źle skonfigurowałem (chyba źle podaje driver do PostgreSql). No ale co zmienię to mam ten sam błąd i już nie wiem co robić.

Moje application.properites:

Kopiuj
spring.jpa.database=POSTGRESQL
spring.datasource.platform=postgres
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=create-drop
spring.database.driverClassName=org.postgresql.Driver
spring.datasource.url=jdbc:postgresql://localhost:5432/
spring.datasource.username=postgres
spring.datasource.password=postgres

Mój build.gradle:

Kopiuj
 buildscript {
	ext {
		springBootVersion = '1.4.3.RELEASE'
	}
	repositories {
		mavenCentral()
	}
	dependencies {
		classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
		classpath 'postgresql:postgresql:9.1-901-1.jdbc4'
	}
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'war'

jar {
	baseName = 'conf'
	version = '0.0.1-SNAPSHOT'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
	mavenCentral()
}



dependencies {
	compile('org.springframework.boot:spring-boot-starter-data-jpa')
	compile('org.springframework.boot:spring-boot-starter-jdbc')
	compile('org.springframework.boot:spring-boot-starter-mail')
	compile('org.springframework.boot:spring-boot-starter-web')
	compile("postgresql:postgresql:9.1-901.jdbc4")
	testCompile('org.springframework.boot:spring-boot-starter-test')
}

Bardzo bym prosił o zerknięcie, może ktoś wyłapie błąd.

Pozdrawiam

bakeraw2
  • Rejestracja: dni
  • Ostatnio: dni
  • Postów: 400
1

Raczej powinno być:

Kopiuj
 spring.datasource.driverClassName=org.postgresql.Driver

zamiast

Kopiuj
 spring.database.driverClassName=org.postgresql.Driver

IceHeart
  • Rejestracja: dni
  • Ostatnio: dni
  • Postów: 312
0

Niestety to nie pomogło :/

  • Rejestracja: dni
  • Ostatnio: dni
PO
  • Rejestracja: dni
  • Ostatnio: dni
  • Postów: 153
1
Kopiuj
spring.database.driverClassName=org.postgresql.Driver

U siebie jak mam konfiguracje to jako driver mam podane:

Kopiuj
org.postgresql.ds.PGSimpleDataSource
IceHeart
  • Rejestracja: dni
  • Ostatnio: dni
  • Postów: 312
0

Dzięki wszystkim za pomoc, przy takiej konfiguracji (konfigurację wklejam może ktoś będzie miał poodobny błąd) działą.
build.gradle:

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

	}
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'war'

jar {
	baseName = 'conf'
	version = '0.0.1-SNAPSHOT'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
	mavenCentral()
}



dependencies {
	compile('org.springframework.boot:spring-boot-starter-mail')
	compile('org.springframework.boot:spring-boot-starter-actuator')
	compile('org.springframework.boot:spring-boot-starter-data-jpa')
	compile('org.springframework.boot:spring-boot-starter-jdbc')
	compile('org.springframework.boot:spring-boot-starter-web')
	runtime('com.h2database:h2')
	runtime('mysql:mysql-connector-java')
	runtime('org.postgresql:postgresql')
	testCompile('org.springframework.boot:spring-boot-starter-test')
}

application.properties:

Kopiuj
 spring.jpa.database=POSTGRESQL
spring.datasource.platform=postgres
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=create-drop
spring.datasource.driverClassName=org.postgresql.Driver
spring.datasource.url=jdbc:postgresql://localhost:5432/
spring.datasource.username=postgres
spring.datasource.password=postgres


Zarejestruj się i dołącz do największej społeczności programistów w Polsce.

Otrzymaj wsparcie, dziel się wiedzą i rozwijaj swoje umiejętności z najlepszymi.