简体   繁体   English

Java Rest 集成认证错误

[英]Java Rest Integration Authentication error

I am a newbie who started to integrate JIRA using Java, following the issues & document, I am trying to get issues using Java.我是一个新手,开始使用 Java 集成 JIRA,在问题和文档之后,我正在尝试使用 Java 来解决问题。

Everything's fine, but I am getting the following error.一切都很好,但我收到以下错误。

Exception in thread "main" java.lang.IncompatibleClassChangeError: Class com.atlassian.jira.rest.client.auth.BasicHttpAuthenticationHandler does not implement the requested interface com.atlassian.jira.rest.client.api.AuthenticationHandler

This is my pom.xml这是我的 pom.xml

<!-- https://mvnrepository.com/artifact/com.atlassian.jira/jira-rest-java-client -->
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-rest-java-client</artifactId>
<version>1.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.atlassian.jira/jira-rest-java-client-api -->
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-rest-java-client-api</artifactId>
<version>5.1.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.atlassian.jira/jira-rest-java-client-core -->
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-rest-java-client-core</artifactId>
<version>5.1.6</version>
</dependency>

<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-rest-java-client-app</artifactId>
<version>5.2.0</version>
</dependency>
<dependency>
<groupId>com.atlassian.fugue</groupId>
<artifactId>fugue</artifactId>
<version>2.6.1</version>
</dependency>

</dependencies>
<repositories>
<repository>
<id>atlassian-public</id>
<url>https://m2proxy.atlassian.com/repository/public</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>daily</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</snapshots>
<releases>
<enabled>true</enabled>
<checksumPolicy>warn</checksumPolicy>
</releases>
</repository>
</repositories>

<pluginRepositories>
<pluginRepository>
<id>atlassian-public</id>
<url>https://m2proxy.atlassian.com/repository/public</url>
<releases>
<enabled>true</enabled>
<checksumPolicy>warn</checksumPolicy>
</releases>
<snapshots>
<checksumPolicy>warn</checksumPolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>

And this is my code.这是我的代码。

import java.io.IOException;
import java.net.URI;

import com.atlassian.jira.rest.client.api.JiraRestClient;
import com.atlassian.jira.rest.client.api.domain.Issue;
import com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory;

public class Dummy {

private String username;
private String password;
private String jiraUrl;
private JiraRestClient restClient;

private Dummy(String username, String password, String jiraUrl) {
this.username = username;
this.password = password;
this.jiraUrl = jiraUrl;
this.restClient = getJiraRestClient();
}

private JiraRestClient getJiraRestClient() {
return new AsynchronousJiraRestClientFactory().createWithBasicHttpAuthentication(getJiraUri(), this.username,
this.password);
}

private URI getJiraUri() {
return URI.create(this.jiraUrl);
}

private Issue getIssue(String issueKey) {
return restClient.getIssueClient().getIssue(issueKey).claim();
}

public static void main(String[] args) throws IOException {
Dummy myJiraClient = new Dummy("username", "password", "http://localhost:8080/secure/WelcomeToJIRA.jspa");
String issueKey = issueKey;
Issue issue = myJiraClient.getIssue(issueKey);
System.out.println(issue.getDescription());

myJiraClient.restClient.close();
}


}

 

I didn't find any solution for the error, also I don't know where I am wrong.我没有找到任何错误的解决方案,我也不知道我错在哪里。 It would be appreciated if someone helps me out where I am wrong.如果有人帮助我找出我错的地方,我将不胜感激。 Any help is much appreciated.任何帮助深表感谢。

Thank you!谢谢!

It think, it is a dependency conflict.它认为,这是一个依赖冲突。 By using mvn dependency:tree command,.. can analyse and find out.通过使用 mvn dependency:tree 命令,..可以分析找出来。

Also I checked this sample (client) in atlassion bitbucket.我还在 atlassion bitbucket 中检查了这个样本(客户端)。 In this example, atlassian.httpclient.version is 2.0.0 .在此示例中, atlassian.httpclient.version 为2.0.0 Hope this would help.希望这会有所帮助。

https://bitbucket.org/atlassian/jira-rest-java-client/src/master/pom.xml https://bitbucket.org/atlassian/jira-rest-java-client/src/master/pom.xml

https://bitbucket.org/atlassian/jira-rest-java-client/src/75a64c9d81aad7d8bd9beb11e098148407b13cae/test/src/test/java/samples/ExampleCreateIssuesAsynchronous.java?at=master&_ga=2.100062872.72364915.1593881496-21279827.1593881496 https://bitbucket.org/atlassian/jira-rest-java-client/src/75a64c9d81aad7d8bd9beb11e098148407b13cae/test/src/test/java/samples/ExampleCreateIssuesAsynchronous.java?at=master&_ga=2.100062872.72364915.1593881496-21279827.1593881496

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM