我以前在Java中創建了一個穩定的客戶端應用程序來批量操縱票據並加速工作流,但是,我想創建一個更全面的應用程序,它利用實際的JIRA API而不是解析JSON自己解決。 我有一個非常簡單的代碼塊創建一個客戶端:無法創建AsynchronousJiraRestClientFactory(依賴項問題)
public class SimpleMain {
public static void main(String[] args) {
try {
JiraRestClient client = new AsynchronousJiraRestClientFactory()
.createWithBasicHttpAuthentication(new URI("https://jira.redacted.com"), "redacted", "redacted");
} catch (URISyntaxException e) {
e.printStackTrace();
}
}
}
試圖創建以下異常簡單AsynchronousJiraRestClientFactory結果:
15:12:06.625 [main] DEBUG c.a.j.r.c.i.a.AsynchronousHttpClientFactory$MavenUtils - Could not find version for maven artifact com.atlassian.jira:jira-rest-java-com.atlassian.jira.rest.client
15:12:06.633 [main] DEBUG c.a.j.r.c.i.a.AsynchronousHttpClientFactory$MavenUtils - Got the following exception
java.lang.NullPointerException: null
at java.util.Properties$LineReader.readLine(Properties.java:434) ~[na:1.8.0_51]
at java.util.Properties.load0(Properties.java:353) ~[na:1.8.0_51]
at java.util.Properties.load(Properties.java:341) ~[na:1.8.0_51]
at com.atlassian.jira.rest.client.internal.async.AsynchronousHttpClientFactory$MavenUtils.getVersion(AsynchronousHttpClientFactory.java:158) ~[jira-rest-java-client-core-3.0.0.jar:na]
at com.atlassian.jira.rest.client.internal.async.AsynchronousHttpClientFactory$RestClientApplicationProperties.getVersion(AsynchronousHttpClientFactory.java:121) [jira-rest-java-client-core-3.0.0.jar:na]
at com.atlassian.httpclient.apache.httpcomponents.DefaultHttpClient.getUserAgent(DefaultHttpClient.java:168) [atlassian-httpclient-apache-httpcomponents-0.13.2.jar:na]
at com.atlassian.httpclient.apache.httpcomponents.DefaultHttpClient.<init>(DefaultHttpClient.java:139) [atlassian-httpclient-apache-httpcomponents-0.13.2.jar:na]
at com.atlassian.jira.rest.client.internal.async.AsynchronousHttpClientFactory.createClient(AsynchronousHttpClientFactory.java:53) [jira-rest-java-client-core-3.0.0.jar:na]
at com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory.create(AsynchronousJiraRestClientFactory.java:35) [jira-rest-java-client-core-3.0.0.jar:na]
at com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory.createWithBasicHttpAuthentication(AsynchronousJiraRestClientFactory.java:42) [jira-rest-java-client-core-3.0.0.jar:na]
at jiratest.SimpleMain.main(SimpleMain.java:13) [classes/:na]
Exception in thread "main" java.lang.NoSuchMethodError: org.apache.http.nio.client.HttpAsyncClient.start()V
at com.atlassian.httpclient.apache.httpcomponents.DefaultHttpClient.<init>(DefaultHttpClient.java:162)
Disconnected from the target VM, address: '127.0.0.1:53429', transport: 'socket'
at com.atlassian.jira.rest.client.internal.async.AsynchronousHttpClientFactory.createClient(AsynchronousHttpClientFactory.java:53)
at com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory.create(AsynchronousJiraRestClientFactory.java:35)
at com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory.createWithBasicHttpAuthentication(AsynchronousJiraRestClientFactory.java:42)
at jiratest.SimpleMain.main(SimpleMain.java:13)
從我一直在讀什麼,這是一個由於不同的庫,因此存在依賴性問題。這是我用的:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<pojomatic.version>2.0.1</pojomatic.version>
<jira-api.version>6.1.1</jira-api.version>
<jira-rest-java-client-core.version>3.0.0</jira-rest-java-client-core.version>
<httpcore.version>4.4.1</httpcore.version>
<commons-io.version>2.4</commons-io.version>
</properties>
<dependencies>
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-api</artifactId>
<version>${jira-api.version}</version>
</dependency>
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-rest-java-client-core</artifactId>
<version>${jira-rest-java-client-core.version}</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>${httpcore.version}</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>${httpcore.version}</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore-nio</artifactId>
<version>${httpcore.version}</version>
</dependency>
<dependency>
<groupId>org.pojomatic</groupId>
<artifactId>pojomatic</artifactId>
<version>${pojomatic.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-batch</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
有誰知道我應該使用什麼版本?我仍然缺少依賴關係嗎?我一直在閱讀亞特蘭大的q/a和各種谷歌文檔,我認爲我很接近,但我不確定我還缺少什麼。
感謝所有提前:)
在'依賴性:tree'我看到exaclty這兩個依賴和增加你的建議的dependecyManagement部分沒有幫助擺脫NullPointerException :( – dokaspar
可能你有另一個與jrjc核心發生衝突的依賴項。運行'mvn dependency:tree'並查看你是否看到任何'受管理的'消息在dependencyManagement部分將它們拉到from版本,然後漂洗並重復。有時候,如果你有多個依賴關係,你實際上會被拉到多個ti mes,而不是一次給定的依賴關係,所以唯一的方法是知道多次管理/檢查。 –
@dokaspar這很可能已經太晚了,我只是意識到這可能是因爲你需要清理你的老依賴的maven項目。 'mvn clean install -B -U'去除然後收集由pom文件定義的最新的依賴關係。 –