我后来发现了一个很好的替代方法:添加自定义代码操作:
List<Integer> takenPorts = new ArrayList<Integer>();
for (int port : Arrays.asList(80, 443)) {
java.net.ServerSocket socket = null;
try {
socket = new java.net.ServerSocket(port);
} catch (IOException e) {
takenPorts.add(port);
} finally {
if (socket != null) socket.close();
}
}
if (takenPorts.isEmpty()) {
return true;
}
else {
String msg;
if (takenPorts.size() == 2) {
msg = "Ports 80 and 443 must be available for uDiscovery";
}
else {
msg = "Port " + takenPorts.get(0) + " must be available for uDiscovery";
}
context.setVariable("portErrorMessage", msg);
return false;
}
很好地解释了如何在这里连接它