无法在Gradle项目中解析Spring Tool Suite org.joda

问题描述 投票:0回答:1

我已经使用Spring Tool Suite启动了Gradle项目。遵循本教程:https://spring.io/guides/gs/gradle/,它指示我应该在build.gradle文件中添加org.joda依赖项,将依赖项导入类,构建程序包,然后可以使用它。但是,当我这样做并重新生成项目并运行它时,出现错误:

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)

我的依赖项似乎已正确设置:

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项目中导入此依赖关系并进行编译?

我的整个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.8
targetCompatibility = 1.8

jar {
    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')
}
java spring spring-boot gradle spring-tool-suite
1个回答
0
投票

https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.2-Release-Notes

不赞成使用Joda时间,而建议使用java.time。

© www.soinside.com 2019 - 2024. All rights reserved.