类 PortInUseException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
org.springframework.boot.web.server.WebServerException
org.springframework.boot.web.server.PortInUseException
- 所有已实现的接口:
Serializable
A
PortInUseException
is thrown when a web server fails to start due to a port
already being in use.- 从以下版本开始:
- 2.0.0
- 作者:
- Andy Wilkinson, Phillip Webb
- 另请参阅:
-
构造器概要
构造器构造器说明PortInUseException
(int port) Creates a new port in use exception for the givenport
.PortInUseException
(int port, Throwable cause) Creates a new port in use exception for the givenport
. -
方法概要
修饰符和类型方法说明int
getPort()
Returns the port that was in use.static <E extends Exception>
voidifCausedBy
(Exception ex, Class<E> causedBy, Consumer<E> action) Perform an action if the given exception was caused by a specific exception type.static void
ifPortBindingException
(Exception ex, Consumer<BindException> action) Perform an action if the given exception was caused by a "port in use"BindException
.static void
throwIfPortBindingException
(Exception ex, IntSupplier port) Throw aPortInUseException
if the given exception was caused by a "port in use"BindException
.
-
构造器详细资料
-
PortInUseException
public PortInUseException(int port) Creates a new port in use exception for the givenport
.- 参数:
port
- the port that was in use
-
PortInUseException
Creates a new port in use exception for the givenport
.- 参数:
port
- the port that was in usecause
- the cause of the exception
-
-
方法详细资料
-
getPort
public int getPort()Returns the port that was in use.- 返回:
- the port
-
throwIfPortBindingException
Throw aPortInUseException
if the given exception was caused by a "port in use"BindException
.- 参数:
ex
- the source exceptionport
- a suppler used to provide the port- 从以下版本开始:
- 2.2.7
-
ifPortBindingException
Perform an action if the given exception was caused by a "port in use"BindException
.- 参数:
ex
- the source exceptionaction
- the action to perform- 从以下版本开始:
- 2.2.7
-
ifCausedBy
public static <E extends Exception> void ifCausedBy(Exception ex, Class<E> causedBy, Consumer<E> action) Perform an action if the given exception was caused by a specific exception type.- 类型参数:
E
- the cause exception type- 参数:
ex
- the source exceptioncausedBy
- the required cause typeaction
- the action to perform- 从以下版本开始:
- 2.2.7
-