我试图抓住弹簧数据审核。所以我从一个简单的build.gragle开始,我在下面写道。但我无法获得javax.persistence的所有类。*我的意思是@Entity
超过任何POJO给我无法解析符号而且没有可用的导入。我无法弄清楚我是什么在我的gradle文件中丢失。
buildscript {
ext {
springBootVersion = '1.5.2.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
jar {
baseName = 'auditTest'
version = '1.0.0-SNAPSHOT'
}
repositories {
mavenCentral()
mavenLocal()
}
group = 'com.shubham'
version = '1.0.0-SNAPSHOT'
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.springframework.data:spring-data-jpa:1.11.1.RELEASE')
}
但后来我从Spring's Getting Started with JPA页面复制了gradle文件。 javax.persistance
的所有课程都可用。
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.5.2.RELEASE")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
jar {
baseName = 'Audit'
version = '0.1.0'
}
repositories {
mavenCentral()
maven { url "https://repository.jboss.org/nexus/content/repositories/releases" }
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
compile("org.springframework.boot:spring-boot-starter-data-jpa")
testCompile("org.springframework.boot:spring-boot-starter-test")
}
那么我在build.gradle
文件中遗漏了什么?
答案 0 :(得分:1)
查看gradle(gradlew dependencies
)
+--- org.springframework.boot:spring-boot-starter-data-jpa: -> 1.4.3.RELEASE
| +--- org.springframework.boot:spring-boot-starter:1.4.3.RELEASE (*)
| +--- org.springframework.boot:spring-boot-starter-aop:1.4.3.RELEASE
| | +--- org.springframework.boot:spring-boot-starter:1.4.3.RELEASE (*)
| | +--- org.springframework:spring-aop:4.3.5.RELEASE (*)
| | \--- org.aspectj:aspectjweaver:1.8.9
| +--- org.springframework.boot:spring-boot-starter-jdbc:1.4.3.RELEASE
| | +--- org.springframework.boot:spring-boot-starter:1.4.3.RELEASE (*)
| | +--- org.apache.tomcat:tomcat-jdbc:8.5.6
| | | \--- org.apache.tomcat:tomcat-juli:8.5.6
| | \--- org.springframework:spring-jdbc:4.3.5.RELEASE
| | +--- org.springframework:spring-beans:4.3.5.RELEASE (*)
| | +--- org.springframework:spring-core:4.3.5.RELEASE
| | \--- org.springframework:spring-tx:4.3.5.RELEASE
| | +--- org.springframework:spring-beans:4.3.5.RELEASE (*)
| | \--- org.springframework:spring-core:4.3.5.RELEASE
| +--- org.hibernate:hibernate-core:5.0.11.Final
| | +--- org.jboss.logging:jboss-logging:3.3.0.Final
| | +--- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.0.Final
| | +--- org.javassist:javassist:3.18.1-GA -> 3.20.0-GA
| | +--- antlr:antlr:2.7.7
| | +--- org.jboss:jandex:2.0.0.Final
| | +--- dom4j:dom4j:1.6.1
| | | \--- xml-apis:xml-apis:1.0.b2 -> 1.4.01
| | \--- org.hibernate.common:hibernate-commons-annotations:5.0.1.Final
| | \--- org.jboss.logging:jboss-logging:3.3.0.Final
| +--- org.hibernate:hibernate-entitymanager:5.0.11.Final
| | +--- org.jboss.logging:jboss-logging:3.3.0.Final
| | +--- org.hibernate:hibernate-core:5.0.11.Final (*)
| | +--- dom4j:dom4j:1.6.1 (*)
| | +--- org.hibernate.common:hibernate-commons-annotations:5.0.1.Final (*)
| | +--- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.0.Final
| | \--- org.javassist:javassist:3.18.1-GA -> 3.20.0-GA
| +--- javax.transaction:javax.transaction-api:1.2
| +--- org.springframework.data:spring-data-jpa:1.10.6.RELEASE
| | +--- org.springframework.data:spring-data-commons:1.12.6.RELEASE
| | | +--- org.springframework:spring-core:4.2.9.RELEASE -> 4.3.5.RELEASE
| | | +--- org.springframework:spring-beans:4.2.9.RELEASE -> 4.3.5.RELEASE (*)
| | | +--- org.slf4j:slf4j-api:1.7.22
| | | \--- org.slf4j:jcl-over-slf4j:1.7.22 (*)
| | +--- org.springframework:spring-orm:4.2.9.RELEASE -> 4.3.5.RELEASE
| | | +--- org.springframework:spring-beans:4.3.5.RELEASE (*)
| | | +--- org.springframework:spring-core:4.3.5.RELEASE
| | | +--- org.springframework:spring-jdbc:4.3.5.RELEASE (*)
| | | \--- org.springframework:spring-tx:4.3.5.RELEASE (*)
| | +--- org.springframework:spring-context:4.2.9.RELEASE -> 4.3.5.RELEASE (*)
| | +--- org.springframework:spring-aop:4.2.9.RELEASE -> 4.3.5.RELEASE (*)
| | +--- org.springframework:spring-tx:4.2.9.RELEASE -> 4.3.5.RELEASE (*)
| | +--- org.springframework:spring-beans:4.2.9.RELEASE -> 4.3.5.RELEASE (*)
| | +--- org.springframework:spring-core:4.2.9.RELEASE -> 4.3.5.RELEASE
| | +--- org.slf4j:slf4j-api:1.7.22
| | \--- org.slf4j:jcl-over-slf4j:1.7.22 (*)
| \--- org.springframework:spring-aspects:4.3.5.RELEASE
| \--- org.aspectj:aspectjweaver:1.8.9
我看到org.hibernate.javax.persistence:hibernate-jpa-2.1-api
(javax.persistence。*所在的位置)不依赖于org.springframework.data:spring-data-jpa
。相反,它取决于org.hibernate:hibernate-core
和org.hibernate:hibernate-entitymanager
。
因此,您还应该编译这些包,或者使用org.springframework.boot:spring-boot-starter-data-jpa
。