我有 build.gradle 文件:
onClick
构建任务成功执行:
group 'com.test'
version '1.0'
apply plugin: 'java'
sourceCompatibility = 1.5
jar {
baseName = 'test'
version = '0.0.1'
}
repositories {
jcenter()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
ext{
//versions of dependencies
springVersion = '5.0.4.RELEASE'
springBootVersion = '2.0.0.RELEASE'
springJPAVersion = '2.0.5.RELEASE'
javaxVersion = '1.0.2'
}
dependencies {
implementation "org.springframework.boot:spring-boot-starter-web:${springBootVersion}"
implementation "org.springframework.boot:spring-boot-starter-data-jpa:${springBootVersion}"
implementation "org.springframework.data:spring-data-jpa:${springJPAVersion}"
implementation "javax.persistence:persistence-api:${javaxVersion}"
testImplementation group: 'junit', name: 'junit', version: '4.11'
}
在 C:\ Users \ admin.gradle \ caches \ modules-2 \ files-2.1 \ javax.persistence \ persistence-api \ 1.0.2 \ 8 ... a Gradle下载存档 persistence-api-1.0.2.jar ,其中包含 javax \ persistence \ Entity.class 。
但是当我试图添加行时:
21:56:37: Executing external task 'build'...
:compileJava UP-TO-DATE
:processResources NO-SOURCE
:classes UP-TO-DATE
:jar UP-TO-DATE
:assemble UP-TO-DATE
:compileTestJava NO-SOURCE
:processTestResources NO-SOURCE
:testClasses UP-TO-DATE
:test NO-SOURCE
:check UP-TO-DATE
:build UP-TO-DATE
BUILD SUCCESSFUL in 0s
2 actionable tasks: 2 up-to-date
21:56:37: External task execution finished 'build'.
在任何一个类中,IntelliJ Idea都用红色强调持久性。为什么以及如何解决它?