我正在按照https://spring.io/guides/gs/accessing-data-mysql/上的指南开始将MySQL用于Gradle项目,但是,当我尝试在@Entity注释中添加所有内容时
这是我的build.gradle,它在网站上遵循相同的内容:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.0.5.RELEASE")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
bootJar {
baseName = 'gs-accessing-data-mysql'
version = '0.1.0'
}
repositories {
mavenCentral()
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
compile("org.springframework.boot:spring-boot-starter-web")
// JPA Data (We are going to use Repositories, Entities, Hibernate, etc...)
compile 'org.springframework.boot:spring-boot-starter-data-jpa'
compile group: 'javax.persistence', name: 'persistence-api', version: '1.0'
// Use MySQL Connector-J
compile 'mysql:mysql-connector-java'
testCompile('org.springframework.boot:spring-boot-starter-test')
}
答案 0 :(得分:1)
删除compile group: 'javax.persistence', name: 'persistence-api', version: '1.0'
,然后再尝试以下操作,因为jar可能已损坏。
运行./gradlew clean install
,然后检查。.
如果上述方法不起作用:然后delete ~/.gradle/caches
并再次运行gradle install命令以重新导入所有依赖项。
重新启动IDE,然后再次导入项目。
答案 1 :(得分:0)