Commit c678f70836dda351ec1a4e9c6bd18898b97faad3
1 parent
a2ad5773
优化启动IP信息获取逻辑
Signed-off-by: TanYibin <5491541@qq.com>
Showing
1 changed file
with
3 additions
and
5 deletions
huaheng-wms-core/src/main/java/org/jeecg/JeecgSystemApplication.java
... | ... | @@ -57,8 +57,6 @@ public class JeecgSystemApplication extends SpringBootServletInitializer { |
57 | 57 | |
58 | 58 | public static InetAddress getLocalHostExactAddress() { |
59 | 59 | try { |
60 | - InetAddress inetAddress = null; | |
61 | - | |
62 | 60 | Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces(); |
63 | 61 | while (networkInterfaces.hasMoreElements()) { |
64 | 62 | NetworkInterface netInterface = networkInterfaces.nextElement(); |
... | ... | @@ -67,12 +65,12 @@ public class JeecgSystemApplication extends SpringBootServletInitializer { |
67 | 65 | while (addresses.hasMoreElements()) { |
68 | 66 | InetAddress ipTmp = addresses.nextElement(); |
69 | 67 | if (ipTmp != null && ipTmp instanceof Inet4Address && ipTmp.isSiteLocalAddress() && !ipTmp.isLoopbackAddress() |
70 | - && ipTmp.getHostAddress().indexOf(":") == -1) { | |
71 | - inetAddress = ipTmp; | |
68 | + && ipTmp.getHostAddress().indexOf(":") == -1 && !ipTmp.getHostAddress().endsWith(".1")) { | |
69 | + return ipTmp; | |
72 | 70 | } |
73 | 71 | } |
74 | 72 | } |
75 | - return inetAddress == null ? InetAddress.getLocalHost() : inetAddress; | |
73 | + return InetAddress.getLocalHost(); | |
76 | 74 | } catch (SocketException | UnknownHostException e) { |
77 | 75 | e.printStackTrace(); |
78 | 76 | } |
... | ... |