我已經使用 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.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')}
添加回答
舉報
0/150
提交
取消