我正在尝试按照 this 在 IntelliJ 中使用 Gradle 设置 AWS Polly Java SDK 。我已经使用 spring intializr
创建了一个简单的 Spring Boot 应用程序,因此我将教程中指定的项目添加到我的 build.gradle
文件中。当尝试导入时
import com.amazonaws.services.polly.AmazonPollyClient
IntelliJ 无法解析名称 polly
。
这是我的完整 build.gradle
文件
buildscript {
ext {
springBootVersion = '2.0.4.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath "io.spring.gradle:dependency-management-plugin:1.0.3.RELEASE"
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
group = 'io.ai.vivid'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencyManagement {
imports {
mavenBom 'com.amazonaws:aws-java-sdk-bom:1.11.228'
}
}
dependencies {
compile('org.springframework.boot:spring-boot-starter')
testCompile('org.springframework.boot:spring-boot-starter-test')
compile 'com.amazonaws:aws-java-sdk-s3'
testCompile group: 'junit', name: 'junit', version: '4.11'
}
此外,IntelliJ 还提示它无法解析我的 build.gradle
中的名称 manvenBom
。我已经尝试过一些解决方案,例如无效缓存/重新启动,但无法解决问题。
最佳答案
我使用您的 build.gradle
文件来复制问题,并在对依赖项
进行以下更改后能够导入 AmazonPollyClient
dependencies {
compile 'com.amazonaws:aws-java-sdk-s3'
compile group: 'com.amazonaws', name: 'aws-java-sdk-polly', version: '1.11.67'
使用的Gradle版本为4.8
关于java - 如何在 IntetlliJ 中使用 Gradle 设置 Amazon Polly SDK,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51635301/