import org.openapitools不起作用

xsuvu9jc  于 2021-07-08  发布在  Java
关注(0)|答案(0)|浏览(311)

在intellij idea中,我正在测试这个代码。我用gradle,java1.8创建了一个项目。我有合适的sdk。基本上,org.openapitools的导入不起作用,我也不知道该放什么依赖项了,因为我尝试了很多东西,但都没用。
以下代码来自avalara通信sdk。我想试试这个,但我做不到。

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设置,gradlejvm似乎无法识别javau home。我不知道这是否重要,因为我实际上有projectsdk选项。我给其他人改了,1.8,也没什么。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题