Java 在gradle中导入org.openapitools不起作用
在Intellij IDEA中,我正在测试这段代码。我用Gradle,Java1.8创建了一个项目。我有正确的SDK。基本上,来自的导入不起作用,我不知道应该放什么依赖项,因为我尝试了很多东西,但都不起作用 以下代码来自AVALARA communications SDK。我想要的是尝试,但我不能让它工作Java 在gradle中导入org.openapitools不起作用,java,gradle,intellij-idea,java-8,build.gradle,Java,Gradle,Intellij Idea,Java 8,Build.gradle,在Intellij IDEA中,我正在测试这段代码。我用Gradle,Java1.8创建了一个项目。我有正确的SDK。基本上,来自的导入不起作用,我不知道应该放什么依赖项,因为我尝试了很多东西,但都不起作用 以下代码来自AVALARA communications SDK。我想要的是尝试,但我不能让它工作 import org.openapitools.client.ApiClient; import org.openapitools.client.ApiException; import or
import org.openapitools.client.ApiClient;
import org.openapitools.client.ApiException;
import org.openapitools.client.Configuration;
import org.openapitools.client.auth.*;
import org.openapitools.client.models.*;
import org.openapitools.client.api.CustomizationApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("http://localhost");
CustomizationApi apiInstance = new CustomizationApi(defaultClient);
Integer requestedClientId = 56; // Integer | Client id associated with profile(s) to be fetched Null value will use client id submitting the request or default client id as applicable.
Integer requestedProfileId = 56; // Integer | Configuration profile id to be fetched Use 0 to indicate all profiles Null value will use profile id from request or 0 if not set.
TaxCalculationSettingTypes itemType = new TaxCalculationSettingTypes(); // TaxCalculationSettingTypes | Item Type Examples: Configuration, Bundle, Exclusion, Override, All
try {
TaxCalculationSettingsResponse result = apiInstance.apiV2ProfilesGetProfilesGet(requestedClientId, requestedProfileId, itemType);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling CustomizationApi#apiV2ProfilesGetProfilesGet");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
但它不承认任何进口。在build.gradle
中,我有:
buildscript {
repositories {
mavenLocal()
maven { url "https://repo1.maven.org/maven2" }
}
dependencies {
classpath "org.openapitools:openapi-generator-gradle-plugin:3.3.4"
}
}
plugins {
id 'java'
id "org.openapi.generator" version "4.3.1"
}
apply plugin: 'org.openapi.generator'
我也在build.gradle
中尝试过这一点:
plugins {
id 'java'
}
group 'org.example'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
// https://mvnrepository.com/artifact/org.openapitools/openapi-generator
compile group: 'org.openapitools', name: 'openapi-generator', version: '4.3.1'
}
更新:最近查看Intellij设置,Gradle JVM似乎无法识别JAVA_主页。我不知道这是否重要,因为我实际上有projectsdk选项。我把它换成了其他的,1.8,也没有