[英]javax.persistance.Entity not getting imported?
I was trying to get my hands on spring data auditing. 我正尝试着手进行春季数据审核。 So I started with a simple build.gragle which I wrote below.
因此,我从下面编写的简单build.gragle开始。 But I was not able to get all the classes for javax.persistence.* What I mean is
@Entity
over any POJO was giving me cannot resolve symbol and there was no import available.I am not able to figure what I was missing in my gradle file. 但是我无法获得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')
}
But then I copied the gradle file from Spring's Getting Started with JPA page. 但是后来我从Spring的JPA入门页面复制了gradle文件。 And all the classes for
javax.persistance
were available. 并且所有
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")
}
So what was I missing in my build.gradle
file ? 那么我的
build.gradle
文件中缺少什么?
Looking at the dependency graph of gradle ( gradlew dependencies
) 查看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
I see that org.hibernate.javax.persistence:hibernate-jpa-2.1-api
(where javax.persistence.* is situated) is not dependent on org.springframework.data:spring-data-jpa
. 我看到
org.hibernate.javax.persistence:hibernate-jpa-2.1-api
(位于javax.persistence。*所在的位置)不依赖于org.springframework.data:spring-data-jpa
。 Instead it depends on org.hibernate:hibernate-core
and org.hibernate:hibernate-entitymanager
. 相反,它取决于
org.hibernate:hibernate-core
和org.hibernate:hibernate-entitymanager
。
So you should also compile these packages or stay with org.springframework.boot:spring-boot-starter-data-jpa
. 因此,您还应该编译这些软件包或与
org.springframework.boot:spring-boot-starter-data-jpa
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.