Atlassian JIRA Java REST API赋格问题

s6fujrry  于 2023-01-29  发布在  Java
关注(0)|答案(3)|浏览(387)

I want to fetch data from a JIRA server using a simple Java program.
I got this in my POM, after trying a lot of different solutions found here and there.

<repositories>
    <repository>
        <id>atlassian-public</id>
        <url>https://packages.atlassian.com/maven/repository/public</url>
    </repository>
    <repository>
        <id>atlassian-public</id>
        <url>https://mvnrepository.cpm/artifact/com.atlassian.fugue/fugue</url>
    </repository>
</repositories>

<dependencies>
    <dependency>
        <groupId>com.atlassian.jira</groupId>
        <artifactId>jira-rest-java-client-core</artifactId>
        <version>5.2.0</version>
    </dependency>
    <dependency>
        <groupId>io.atlassian.fugue</groupId>
        <artifactId>fugue</artifactId>
        <version>4.7.2</version>
        <scope>provided</scope>
    </dependency>
</dependencies>

My project builds, but when I run it I get the problem description below. I believe the simple logger is a warning, but what should I have done for io.atlassian.fugue to be found during runtime?
best rgds,
Niklas
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. Exception in thread "main" java.lang.NoClassDefFoundError: io/atlassian/fugue/Suppliers at com.atlassian.httpclient.apache.httpcomponents.ApacheAsyncHttpClient.(ApacheAsyncHttpClient.java:80) at com.atlassian.httpclient.apache.httpcomponents.DefaultHttpClientFactory.doCreate(DefaultHttpClientFactory.java:61) at com.atlassian.httpclient.apache.httpcomponents.DefaultHttpClientFactory.create(DefaultHttpClientFactory.java:36) at com.atlassian.jira.rest.client.internal.async.AsynchronousHttpClientFactory.createClient(AsynchronousHttpClientFactory.java:65) at com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory.create(AsynchronousJiraRestClientFactory.java:36) at com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory.createWithAuthenticationHandler(AsynchronousJiraRestClientFactory.java:47) at MyJiraClient.getJiraRestClient(MyJiraClient.java:44) at MyJiraClient.(MyJiraClient.java:27) at MyJiraClient.main(MyJiraClient.java:31) Caused by: java.lang.ClassNotFoundException: io.atlassian.fugue.Suppliers at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:602) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) ... 9 more

wkftcu5l

wkftcu5l1#

这可能是jira-rest-java-client-core(JRJC)和io.atlassian.fugue版本不能一起工作的问题。JRJC需要赋格,但你需要将赋格的正确版本与给定的JRJC版本一起使用。
我也曾为此挣扎过,但除了尝试(失败),我没有找到任何地方/任何方法来确定哪个赋格版本实际上能与最新的JRJC版本很好地工作。我在Baeldung上遵循了一个例子,但那里使用的JRJC版本是旧的(4.0.0),所以我想使用更新的版本。
通过反复试验,我发现这些版本配合得很好,但JRJC版本并不是最新的版本:

<dependency>
    <groupId>com.atlassian.jira</groupId>
    <artifactId>jira-rest-java-client-core</artifactId>
    <version>5.1.0</version>
</dependency>

<dependency>
    <groupId>io.atlassian.fugue</groupId>
    <artifactId>fugue</artifactId>
    <version>4.7.2</version>
</dependency>

还要注意(如Baeldung示例所示)有一个groupId为com.atlassian.fugue(而不是io.atlassian.fugue)的赋格人工产物。

bnlyeluc

bnlyeluc2#

首先,SLF4J:无法加载类警告,我认为这与您的主要错误不同,您可以通过添加SLF4J Bridge maven依赖项来清除或修复该警告:

<dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-api</artifactId>
        <version>2.13.3</version>
    </dependency>
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-core</artifactId>
        <version>2.13.3</version>
    </dependency>
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-slf4j-impl</artifactId>
        <version>2.13.3</version>
    </dependency>

稍后你可以分析另一个根本问题。

dwbf0jvd

dwbf0jvd3#

尽管使用java jira客户端非常简单,但奇怪的是版本兼容性不可用。
对于所有使用“spring-cloud-starter-netflix-eureka-client”依赖性的人,我想分享一下我的发现。
我的微服务编译和旋转良好,具有以下依赖项:

<dependency>
        <groupId>com.atlassian.jira</groupId>
        <artifactId>jira-rest-java-client-core</artifactId>
        <version>5.2.4</version>
    </dependency>
    <dependency>
        <groupId>io.atlassian.fugue</groupId>
        <artifactId>fugue</artifactId>
        <version>5.0.0</version>
    </dependency>

但在尝试使用java jira客户端时抛出以下异常:

java.lang.ClassNotFoundException: com.sun.ws.rs.ext.RuntimeDelegateImpl

经过挖掘,我意识到它正在尝试访问来自Spring Boot Eureka 客户端的旧版本jsr 311-API
我排除了

<dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
        <exclusions>
            <exclusion>
                <groupId>javax.ws.rs</groupId>
                <artifactId>jsr311-api</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

而且现在运行得很好。希望这能对一些人有所帮助:)

相关问题