I am using spring boot and following is my gradle file
buildscript {
ext {
springBootVersion = '2.0.0.BUILD-SNAPSHOT'
}
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse-wtp'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'war'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
configurations {
providedRuntime
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-data-jpa:1.2.1.RELEASE')
compile('org.springframework.boot:spring-boot-starter-web')
compile("com.h2database:h2")
providedRuntime('org.springframework.boot:spring-boot-starter-tomcat')
testCompile('org.springframework.boot:spring-boot-starter-test')
}
while m adding in gradle file the following dependecy
org.springframework.boot:spring-boot-starter-data-jpa:1.2.1.RELEASE
its including bunch of other dependencies like hibernate n all that i don't need it for now(just wanted to use spring data jpa) which cause many other problem so how can i use only spring-data-jpa and its related dependency only ?
tried to disable like exclude = { HibernateJpaAutoConfiguration.class} but does't go well
Thnks in advance
The simplest solution I guess would be just to include spring-data-jpa, not spring-boot-starter-data-jpa:
compile('org.springframework.data:spring-data-jpa:2.0.0.M2')
Or if you're really want to left starter, than you might try to do something like:
compile('org.springframework.boot:spring-boot-starter-data-jpa') {
exclude(module: 'hibernate-core')
exclude(module: 'hibernate-entitymanager')
}
But understand this, in order to use spring-data-jpa you have to have a persistent provider like hibernate, just because spring-data-jpa itself is nothing more than an abstraction on top of JPA which in turn is an abstraction as well on top of persistent providers like hibernate or eclipselink.
Update
If you want to leave all jpa dependencies in gradle build script, but don't want spring-boot to use them for a while, then you have to disable both DataSourceAutoConfiguration and HibernateJpaAutoConfiguration as well.
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With