首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Spring工具套件org.joda无法在Gradle项目中解析

Spring工具套件org.joda无法在Gradle项目中解析
EN

Stack Overflow用户
提问于 2018-08-18 11:23:41
回答 1查看 554关注 0票数 0

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

代码语言:javascript
复制
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)

我的依赖项似乎设置得很合适:

代码语言:javascript
复制
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文件看起来像这样:

代码语言:javascript
复制
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')
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-10-25 07:18:34

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

Joda时间支持被弃用,取而代之的是java.time。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51904962

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档