我尝试使用https://www.baeldung.com/jira-rest-api之后的Java SDK列出JIRA项目(我在Google中找不到其他示例),代码如下:
public static void main(String[] args) {
JiraRestClient jiraRestClient = getJiraRestClient(URI.create("uri"),"username","token");
try {
Iterable<BasicProject> projects = jiraRestClient.getProjectClient().getAllProjects().get();
projects.forEach(basicProject -> System.out.println(basicProject.getName()));
} catch (InterruptedException e) {
throw new RuntimeException(e);
} catch (ExecutionException e) {
throw new RuntimeException(e);
}
}
private static JiraRestClient getJiraRestClient(URI uri, String username, String password) {
return new AsynchronousJiraRestClientFactory()
.createWithBasicHttpAuthentication(uri, username, password);
}
但是,它返回以下错误:
Exception in thread "main" java.lang.NoClassDefFoundError: io/atlassian/fugue/Suppliers
at com.atlassian.httpclient.apache.httpcomponents.ApacheAsyncHttpClient.<clinit>(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:68)
at com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory.create(AsynchronousJiraRestClientFactory.java:36)
at com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory.createWithBasicHttpAuthentication(AsynchronousJiraRestClientFactory.java:42)
at JiraPlayground.getJiraRestClient(JiraPlayground.java:30)
at JiraPlayground.main(JiraPlayground.java:13)
Caused by: java.lang.ClassNotFoundException: io.atlassian.fugue.Suppliers
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 8 more
以下是我的依赖项:
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-rest-java-client-core</artifactId>
<version>5.2.4</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.atlassian.fugue/fugue -->
<dependency>
<groupId>io.atlassian.fugue</groupId>
<artifactId>fugue</artifactId>
<version>5.0.0</version>
<scope>provided</scope>
</dependency>
知道如何正确运行代码吗?
3条答案
按热度按时间4nkexdtk1#
这是一个很长的机会,但我建议将库 fugue 的范围从
provided
更改为compile
,然后重试...vcirk6k62#
这对我很有效:
如https://stackoverflow.com/a/75527051/309683中所述,如果您在Jira外部运行应用程序(例如,不是插件/扩展),请确保
fuge
未标记为provided
。那么下面的代码应该可以工作:
brgchamk3#
io.atlassian.fugue.Suppliers
类是JRJC maven依赖项中未包含的不同工件的一部分。这会在运行时导致异常。尝试将以下依赖项添加到
pom.xml
: