我已經(jīng)使用 Spring Tool Suite 啟動了一個 Gradle 項(xiàng)目。按照本教程:https : //spring.io/guides/gs/gradle/ 它表明我應(yīng)該在我的 build.gradle 文件中添加 org.joda 依賴項(xiàng),在類中導(dǎo)入依賴項(xiàng),構(gòu)建包,然后它應(yīng)該可以使用。但是,當(dāng)我這樣做并重新構(gòu)建項(xiàng)目并運(yùn)行它時,出現(xiàn)錯誤:Exception in thread "main" java.lang.Error: Unresolved compilation problems: LocalTime cannot be resolved to a type LocalTime cannot be resolved to a type at firstGradleProject.HelloWorld.main(HelloWorld.java:7)我的依賴項(xiàng)似乎已正確設(shè)置:dependencies { compile('org.springframework.boot:spring-boot-starter') testCompile('org.springframework.boot:spring-boot-starter-test') compile('joda-time:joda-time:2.2') testCompile('junit:junit:4.12')}如何在我的 Gradle Spring 項(xiàng)目中導(dǎo)入這個依賴項(xiàng)并讓它編譯?我的整個 build.gradle 文件看起來像:buildscript { ext { springBootVersion = '2.0.4.RELEASE' } repositories { mavenCentral() } dependencies { classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") }}apply plugin: 'java'apply plugin: 'eclipse'apply plugin: 'org.springframework.boot'apply plugin: 'io.spring.dependency-management'group = 'com.example'version = '0.0.1-SNAPSHOT'sourceCompatibility = 1.8targetCompatibility = 1.8jar { baseName = 'gs-gradle' version = '0.1.0'}repositories { mavenCentral()}dependencies { compile('org.springframework.boot:spring-boot-starter') testCompile('org.springframework.boot:spring-boot-starter-test') compile('joda-time:joda-time:2.2') testCompile('junit:junit:4.12')}
Spring Tool Suite org.joda 在 Gradle 項(xiàng)目中無法解析
慕標(biāo)琳琳
2021-07-21 17:46:09