声纳客户端 org.sonar.wsclient.base.HttpException:错误 407
Sonar client org.sonar.wsclient.base.HttpException: Error 407
我正在使用声纳客户端 API 以在个性化版本中显示代码味道。但是我在这样做时遇到了上述错误?在我以前获取输出之前。
public class ab{
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);
}
}
当您尝试访问的资源需要 代理身份验证 时,将抛出 Http Error 407
。但是当您通过 127.0.0.1 访问该服务时,这表明它是您的本地系统,您不应该得到 407
错误。尝试将条目添加到您的主机文件中(在 YOUR_WINDOWS_FOLDER\System32\drivers\etc 下)as
127.0.0.1 localhost
或者,您是否尝试过通过 localhost
访问 URL,如下所示?
最后,如果 sonarqube 托管在单独的服务器上,您可以在调用服务之前按如下方式设置代理身份验证。
import java.net.Authenticator;
import java.net.InetSocketAddress;
import java.net.PasswordAuthentication;
import java.net.Proxy;
.
.
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("PROXY_SERVER", 80));
Authenticator authenticator = new Authenticator() {
public PasswordAuthentication getPasswordAuthentication() {
return (new PasswordAuthentication("PROXY_USERNAME", "PROXY_PASSWORD".toCharArray()));
}
};
Authenticator.setDefault(authenticator);
我正在使用声纳客户端 API 以在个性化版本中显示代码味道。但是我在这样做时遇到了上述错误?在我以前获取输出之前。
public class ab{
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);
}
}
Http Error 407
。但是当您通过 127.0.0.1 访问该服务时,这表明它是您的本地系统,您不应该得到 407
错误。尝试将条目添加到您的主机文件中(在 YOUR_WINDOWS_FOLDER\System32\drivers\etc 下)as
127.0.0.1 localhost
或者,您是否尝试过通过 localhost
访问 URL,如下所示?
最后,如果 sonarqube 托管在单独的服务器上,您可以在调用服务之前按如下方式设置代理身份验证。
import java.net.Authenticator;
import java.net.InetSocketAddress;
import java.net.PasswordAuthentication;
import java.net.Proxy;
.
.
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("PROXY_SERVER", 80));
Authenticator authenticator = new Authenticator() {
public PasswordAuthentication getPasswordAuthentication() {
return (new PasswordAuthentication("PROXY_USERNAME", "PROXY_PASSWORD".toCharArray()));
}
};
Authenticator.setDefault(authenticator);