Skip to content

Commit

Permalink
不能分配端口时提示信息
Browse files Browse the repository at this point in the history
  • Loading branch information
monkeyWie committed Mar 14, 2018
1 parent bf6d6fd commit 063452a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions ui/src/main/java/lee/study/down/gui/HttpDownApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,15 @@ private void initConfig() throws Exception {
int viewPort = Integer.parseInt(ConfigUtil.getValue("view.server.port"));
int tomcatPort = Integer.parseInt(ConfigUtil.getValue("tomcat.server.port"));
if ("prd".equalsIgnoreCase(ConfigUtil.getValue("spring.profiles.active"))) {
if (OsUtil.isBusyPort(tomcatPort)) {
tomcatPort = OsUtil.getFreePort(tomcatPort + 1);
try {
if (OsUtil.isBusyPort(tomcatPort)) {
tomcatPort = OsUtil.getFreePort(tomcatPort + 1);
}
} catch (Exception e) {
LOGGER.error("getFreePort:", e);
JOptionPane.showMessageDialog(null, "系统异常,请尝试在命令行中执行netsh winsock reset,再运行软件", "运行警告",
JOptionPane.ERROR_MESSAGE);
throw e;
}
viewPort = tomcatPort;
ConfigUtil.setValue("view.server.port", viewPort);
Expand Down

0 comments on commit 063452a

Please sign in to comment.