Java Rest 集成身份验证错误
Java Rest Integration Authentication error
我是一个新手,开始使用 Java 集成 JIRA,根据问题和文档,我正在尝试使用 Java.
解决问题
一切正常,但出现以下错误。
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
这是我的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>
这是我的代码。
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();
}
}
我没有找到任何解决错误的方法,也不知道我哪里错了。如果有人帮助我解决我的错误,我将不胜感激。非常感谢任何帮助。
谢谢!
它认为,这是一个依赖冲突。通过使用 mvn dependency:tree 命令,.. 可以
分析找出来。
我还在 atlassion bitbucket 中检查了这个示例(客户端)。在这个例子中,atlassian.httpclient.version 是 2.0.0。希望这会有所帮助。
https://bitbucket.org/atlassian/jira-rest-java-client/src/master/pom.xml
我是一个新手,开始使用 Java 集成 JIRA,根据问题和文档,我正在尝试使用 Java.
解决问题一切正常,但出现以下错误。
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
这是我的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>
这是我的代码。
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();
}
}
我没有找到任何解决错误的方法,也不知道我哪里错了。如果有人帮助我解决我的错误,我将不胜感激。非常感谢任何帮助。
谢谢!
它认为,这是一个依赖冲突。通过使用 mvn dependency:tree 命令,.. 可以 分析找出来。
我还在 atlassion bitbucket 中检查了这个示例(客户端)。在这个例子中,atlassian.httpclient.version 是 2.0.0。希望这会有所帮助。
https://bitbucket.org/atlassian/jira-rest-java-client/src/master/pom.xml