Spring boot with Gradle


(Kanzari) #1

Hey,

I created a spring boot project and I used gradle, but when I run the build.gradle file it shows me an error

buildscript {
	ext {
		springBootVersion = '1.4.2.RELEASE'
	}
	repositories {
	    jcenter()
	    mavenLocal()
		mavenCentral()
		maven { url "http://repo.spring.io/snapshot" }
		maven { url "http://repo.spring.io/milestone" }
		maven { url "http://repo.spring.io/libs-release" }
		maven { url "http://repo.spring.io/plugins-snapshot"}
	}
	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 = 'AxeleateCommerce'
	version = '0.0.1-SNAPSHOT'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
	jcenter()
	mavenLocal()
	mavenCentral()
	maven { url "http://repo.spring.io/snapshot" }
	maven { url "http://repo.spring.io/milestone" }
	maven { url "http://repo.spring.io/libs-release" }
	maven { url "http://repo.spring.io/plugins-snapshot"}
}


dependencies {
	compile('org.springframework.boot:spring-boot-starter-aop')
	compile('org.springframework.boot:spring-boot-starter-data-jpa')
	compile('org.springframework.boot:spring-boot-starter-data-rest')
	compile('org.springframework.boot:spring-boot-starter-jdbc')
	compile(files("/app/jar/ojdbc6-11.2.0.4.jar"))
	compile('org.springframework.boot:spring-boot-starter-jersey')
	compile('org.springframework.boot:spring-boot-starter-mail')
	compile('org.springframework.boot:spring-boot-starter-mobile')
	compile('org.springframework.boot:spring-boot-starter-security')
	compile('org.springframework.boot:spring-boot-starter-social-facebook')
	compile('org.springframework.boot:spring-boot-starter-social-linkedin')
	compile('org.springframework.boot:spring-boot-starter-social-twitter')
	compile('org.springframework.boot:spring-boot-starter-thymeleaf')
	compile('com.vaadin:vaadin-spring-boot-starter:1.1.0')
	compile('org.springframework.boot:spring-boot-starter-validation')
	compile('org.springframework.boot:spring-boot-starter-web')
	compile('org.springframework.boot:spring-boot-starter-web-services')
	testCompile('org.springframework.boot:spring-boot-starter-test')
}

dependencyManagement {
	imports {
		mavenBom "com.vaadin:vaadin-bom:7.7.3"
	}
}

The error in the eclipse console :

:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:findMainClass
:war
:bootRepackage
:assemble
:compileTestJava UP-TO-DATE
:processTestResources UP-TO-DATE
:testClasses UP-TO-DATE
:test

org.store.AxeleateCommerceApplicationTests > contextLoads FAILED
    java.lang.IllegalStateException
        Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException
            Caused by: org.springframework.beans.factory.BeanCreationException
                Caused by: org.springframework.beans.BeanInstantiationException
                    Caused by: org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException

1 test completed, 1 failed
:test FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':test'.
> There were failing tests. See the report at: file:///app/workspace/AxeleateCommerce/build/reports/tests/index.html

* Try:

BUILD FAILED

Total time: 8.04 secs
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

how to solve this problem.
thanx.


(aleks marchanka) #2

it looks like not a gradle problem.
Problem with
Caused by: org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException
related to your resources or springboot itself.
Try
@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})
or revise your jdbc settings in test resources.