1
我需要編寫Java代碼,用SonarQube的完整描述來檢索問題列表。我用聲納WS客戶端JAR寫下面的代碼,但我得到以下錯誤:如何使用帶Java代碼的Sonar WS Client獲取問題列表?
java.lang.IllegalStateException: Fail to request 127.0.0.1:9001/api/issues/search?rules=Major,Minor,Critical
public class App {
public static void main(String args[]) {
try {
String url = "http://127.0.0.1:9001";
String login = "admin";
String password = "admin";
SonarClient client = SonarClient.builder()
.url(url)
.login(login)
.password(password)
.build();
IssueQuery query = IssueQuery.create();
query.rules("Major","Minor","Critical");
IssueClient issueClient = client.issueClient();
Issues issues = issueClient.find(query);
List<Issue> issueList = issues.list();
for (int i = 0; i < issueList.size(); i++) {
System.out.println(issueList.get(i).projectKey() + " " +
issueList.get(i).componentKey() + " " +
issueList.get(i).line() + " " +
issueList.get(i).ruleKey() + " " +
issueList.get(i).severity() + " " +
issueList.get(i).message());
}
} catch (Exception ex) {
System.out.println(ex);
}
}
}
如何使用聲納WS客戶服務獲得問題列表?
你得到什麼錯誤訊息? –
嗨,我得到了以下錯誤 – karthik
java.lang.IllegalStateException:未能請求http://127.0.0.1:9001/api/issues/search?rules=Major,Minor,Critical – karthik