我是java的新手,所以如果答案是显而易见的,请原谅。我的任务是将java项目转换为Maven,并遇到以下编译错误。
没有为EtHttpException找到合适的构造函数(java.lang.String,java.lang.String)
FWIW相同的错误发生在多个其他类中
基类
public class EtHttpException extends Exception {
private java.lang.String currentURL = null;
private java.lang.String status = null;
private java.lang.String request = null;
/**
EtHttpException constructor comment.
*/
public EtHttpException(String status, String newCurrentURL,Exception e) {
super(status);
currentURL = newCurrentURL;
}
public EtHttpException(String status, String newCurrentURL, String newRequest,Exception e) {
super(status);
currentURL = newCurrentURL;
request = newRequest;
}
public java.lang.String getCurrentURL() {
return currentURL;
}
public java.lang.String getRequest() {
return request;
}
}
错误发生在这里,
public class EtHttpsConnection {
private String sendRequest(String requestMessage, String currentURL)
throws EtHttpException {
String responseMessage = null;
int size = 0;
int offset = 0;
int length = 400;
byte[] buffer = new byte[4096];
try {
setRequest(requestMessage);
responseMessage=connect(currentURL);
trace(currentURL);
trace(requestMessage);
String postRequestMessage =
transformMessageToPostFormat(requestMessage, currentURL);
trace(postRequestMessage);
} catch (Exception e) {
e.printStackTrace();
String msg = e.toString();
disconnect();
throw new EtHttpException(msg, currentURL);
}
// return response
return responseMessage;
}
附加位置错误发生
没有为EtHttpException找到合适的构造函数(java.lang.String,< nulltype >)
public class NoCurrentURLException extends EtHttpException {
public NoCurrentURLException() {
super("No current URL was retrieved from URLList", null);
}
}
我很肯定有一个地方我可以做一个改变,以解决这些错误,有人能提供任何洞察力吗?
发布于 2017-08-28 07:45:44
没有为EtHttpException找到合适的构造函数(java.lang.String,java.lang.String)
错误消息告诉您,EtHttpException没有构造函数,它需要两个字符串。如果您查看EtHttpException,您将看到两个构造函数:一个接受两个String和一个异常;另一个接受三个String和一个异常。
您正在尝试使用两个Strings没有与此签名匹配的构造函数。
要修复它,请将EtHttpsConnection
类中抛出异常的点更改为:
throw new EtHttpException(msg, currentURL, e);
然后更改NoCurrentURLException
类的构造函数,使用如下所示:
super("No current URL was retrieved from URLList", null, null);
https://stackoverflow.com/questions/45922675
复制相似问题