端口被占用问题:The Tomcat connector configured to listen on port 8081 failed to start.

记最近在学springboot,STS(spring tool suite)报错
度了一下整理了三个方法

先上报错

2019-04-29 13:51:14,976 [main] [org.springframework.boot.StartupInfoLogger.logStarting(StartupInfoLogger.java:48)] - [INFO] Starting Application on DESKTOP-U4GVDV7 with PID 2764 (D:\Users\JVeN\Documents\workspace-sts-3.9.8.RELEASE\video-dev\video-dev-mini-api\target\classes started by JVeN in D:\Users\JVeN\Documents\workspace-sts-3.9.8.RELEASE\video-dev\video-dev-mini-api)
2019-04-29 13:51:14,979 [main] [org.springframework.boot.SpringApplication.logStartupProfileInfo(SpringApplication.java:593)] - [INFO] No active profile set, falling back to default profiles: default
2019-04-29 13:51:15,243 [background-preinit] [org.hibernate.validator.internal.util.Version.(Version.java:30)] - [INFO] HV000001: Hibernate Validator 5.3.6.Final
2019-04-29 13:51:15,252 [main] [org.springframework.context.support.AbstractApplicationContext.prepareRefresh(AbstractApplicationContext.java:583)] - [INFO] Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@49e202ad: startup date [Mon Apr 29 13:51:15 CST 2019]; root of context hierarchy
2019-04-29 13:51:15,888 [main] [org.mybatis.spring.mapper.ClassPathMapperScanner.doScan(ClassPathMapperScanner.java:166)] - [WARN] No MyBatis mapper was found in '[com.video.mapper]' package. Please check your configuration.
2019-04-29 13:51:16,110 [main] [org.mybatis.spring.mapper.ClassPathMapperScanner.doScan(ClassPathMapperScanner.java:166)] - [WARN] No MyBatis mapper was found in '[com.video]' package. Please check your configuration.
2019-04-29 13:51:16,119 [main] [org.mybatis.spring.mapper.ClassPathMapperScanner.doScan(ClassPathMapperScanner.java:166)] - [WARN] No MyBatis mapper was found in '[com.video]' package. Please check your configuration.
2019-04-29 13:51:16,168 [main] [org.springframework.data.repository.config.RepositoryConfigurationDelegate.multipleStoresDetected(RepositoryConfigurationDelegate.java:165)] - [INFO] Multiple Spring Data modules found, entering strict repository configuration mode!
2019-04-29 13:51:16,621 [main] [org.springframework.context.support.PostProcessorRegistrationDelegate$BeanPostProcessorChecker.postProcessAfterInitialization(PostProcessorRegistrationDelegate.java:327)] - [INFO] Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$cd9f6485] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-04-29 13:51:17,104 [main] [org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:92)] - [INFO] Tomcat initialized with port(s): 8081 (http)
四月 29, 2019 1:51:17 下午 org.apache.catalina.core.StandardService startInternal
信息: Starting service [Tomcat]
四月 29, 2019 1:51:17 下午 org.apache.catalina.core.StandardEngine startInternal
信息: Starting Servlet Engine: Apache Tomcat/8.5.29
四月 29, 2019 1:51:17 下午 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring embedded WebApplicationContext
2019-04-29 13:51:17,293 [localhost-startStop-1] [org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.prepareEmbeddedWebApplicationContext(EmbeddedWebApplicationContext.java:276)] - [INFO] Root WebApplicationContext: initialization completed in 2044 ms
2019-04-29 13:51:17,555 [localhost-startStop-1] [org.springframework.boot.web.servlet.ServletRegistrationBean.onStartup(ServletRegistrationBean.java:190)] - [INFO] Mapping servlet: 'dispatcherServlet' to [/]
2019-04-29 13:51:17,557 [localhost-startStop-1] [org.springframework.boot.web.servlet.ServletRegistrationBean.onStartup(ServletRegistrationBean.java:190)] - [INFO] Mapping servlet: 'statViewServlet' to [/druid/*]
2019-04-29 13:51:17,561 [localhost-startStop-1] [org.springframework.boot.web.servlet.AbstractFilterRegistrationBean.configure(AbstractFilterRegistrationBean.java:258)] - [INFO] Mapping filter: 'characterEncodingFilter' to: [/*]
2019-04-29 13:51:17,562 [localhost-startStop-1] [org.springframework.boot.web.servlet.AbstractFilterRegistrationBean.configure(AbstractFilterRegistrationBean.java:258)] - [INFO] Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2019-04-29 13:51:17,562 [localhost-startStop-1] [org.springframework.boot.web.servlet.AbstractFilterRegistrationBean.configure(AbstractFilterRegistrationBean.java:258)] - [INFO] Mapping filter: 'httpPutFormContentFilter' to: [/*]
2019-04-29 13:51:17,563 [localhost-startStop-1] [org.springframework.boot.web.servlet.AbstractFilterRegistrationBean.configure(AbstractFilterRegistrationBean.java:258)] - [INFO] Mapping filter: 'requestContextFilter' to: [/*]
2019-04-29 13:51:17,563 [localhost-startStop-1] [org.springframework.boot.web.servlet.AbstractFilterRegistrationBean.configure(AbstractFilterRegistrationBean.java:271)] - [INFO] Mapping filter: 'webStatFilter' to urls: [/*]
2019-04-29 13:51:18,051 [main] [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.initControllerAdviceCache(RequestMappingHandlerAdapter.java:534)] - [INFO] Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@49e202ad: startup date [Mon Apr 29 13:51:15 CST 2019]; root of context hierarchy
2019-04-29 13:51:18,118 [main] [org.springframework.web.servlet.handler.AbstractHandlerMethodMapping$MappingRegistry.register(AbstractHandlerMethodMapping.java:543)] - [INFO] Mapped "{[/hello]}" onto public java.lang.String com.video.controller.HelloWorldController.Hello()
2019-04-29 13:51:18,124 [main] [org.springframework.web.servlet.handler.AbstractHandlerMethodMapping$MappingRegistry.register(AbstractHandlerMethodMapping.java:543)] - [INFO] Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2019-04-29 13:51:18,125 [main] [org.springframework.web.servlet.handler.AbstractHandlerMethodMapping$MappingRegistry.register(AbstractHandlerMethodMapping.java:543)] - [INFO] Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2019-04-29 13:51:18,166 [main] [org.springframework.web.servlet.handler.AbstractUrlHandlerMapping.registerHandler(AbstractUrlHandlerMapping.java:362)] - [INFO] Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2019-04-29 13:51:18,166 [main] [org.springframework.web.servlet.handler.AbstractUrlHandlerMapping.registerHandler(AbstractUrlHandlerMapping.java:362)] - [INFO] Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2019-04-29 13:51:18,232 [main] [org.springframework.web.servlet.handler.AbstractUrlHandlerMapping.registerHandler(AbstractUrlHandlerMapping.java:362)] - [INFO] Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2019-04-29 13:51:18,296 [main] [org.springframework.boot.autoconfigure.thymeleaf.AbstractTemplateResolverConfiguration.checkTemplateLocationExists(AbstractTemplateResolverConfiguration.java:60)] - [WARN] Cannot find template location: classpath:/templates/ (please add some templates or check your Thymeleaf configuration)
2019-04-29 13:51:19,544 [main] [org.springframework.jmx.export.MBeanExporter.afterSingletonsInstantiated(MBeanExporter.java:431)] - [INFO] Registering beans for JMX exposure on startup
2019-04-29 13:51:19,546 [main] [org.springframework.jmx.export.MBeanExporter.autodetect(MBeanExporter.java:918)] - [INFO] Bean with name 'dataSource' has been autodetected for JMX exposure
2019-04-29 13:51:19,551 [main] [org.springframework.jmx.export.MBeanExporter.registerBeanInstance(MBeanExporter.java:672)] - [INFO] Located MBean 'dataSource': registering with JMX server as MBean [com.alibaba.druid.pool:name=dataSource,type=DruidDataSource]
四月 29, 2019 1:51:19 下午 org.apache.catalina.core.StandardService addConnector
严重: Failed to start connector [Connector[HTTP/1.1-8081]]
org.apache.catalina.LifecycleException: Failed to start component [Connector[HTTP/1.1-8081]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
    at org.apache.catalina.core.StandardService.addConnector(StandardService.java:225)
    at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.addPreviouslyRemovedConnectors(TomcatEmbeddedServletContainer.java:265)
    at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.start(TomcatEmbeddedServletContainer.java:208)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.startEmbeddedServletContainer(EmbeddedWebApplicationContext.java:297)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:145)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693)
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)
    at com.video.Application.main(Application.java:15)
Caused by: org.apache.catalina.LifecycleException: Protocol handler start failed
    at org.apache.catalina.connector.Connector.startInternal(Connector.java:1020)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 13 more
Caused by: java.net.BindException: Address already in use: bind
    at sun.nio.ch.Net.bind0(Native Method)
    at sun.nio.ch.Net.bind(Net.java:433)
    at sun.nio.ch.Net.bind(Net.java:425)
    at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
    at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
    at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:210)
    at org.apache.tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.java:1150)
    at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java:591)
    at org.apache.catalina.connector.Connector.startInternal(Connector.java:1018)
    ... 14 more

四月 29, 2019 1:51:19 下午 org.apache.catalina.core.StandardService stopInternal
信息: Stopping service [Tomcat]
2019-04-29 13:51:19,792 [main] [org.springframework.boot.autoconfigure.logging.AutoConfigurationReportLoggingInitializer.logAutoConfigurationReport(AutoConfigurationReportLoggingInitializer.java:101)] - [INFO] 

Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2019-04-29 13:51:19,804 [main] [org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter.report(LoggingFailureAnalysisReporter.java:42)] - [ERROR] 

***************************
APPLICATION FAILED TO START
***************************

Description:

The Tomcat connector configured to listen on port 8081 failed to start. The port may already be in use or the connector may be misconfigured.

Action:

Verify the connector's configuration, identify and stop any process that's listening on port 8081, or configure this application to listen on another port.

2019-04-29 13:51:19,806 [main] [org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:984)] - [INFO] Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@49e202ad: startup date [Mon Apr 29 13:51:15 CST 2019]; root of context hierarchy
2019-04-29 13:51:19,810 [main] [org.springframework.jmx.export.MBeanExporter.destroy(MBeanExporter.java:449)] - [INFO] Unregistering JMX-exposed beans on shutdown
2019-04-29 13:51:19,811 [main] [org.springframework.jmx.support.MBeanRegistrationSupport.unregisterBeans(MBeanRegistrationSupport.java:241)] - [INFO] Unregistering JMX-exposed beans
 来段翻译:

描述:

配置为监听端口8081的Tomcat连接器启动失败。端口可能已经在使用中,或者连接器可能配置错误。

行动:

验证连接器的配置,识别并停止在端口8081上侦听的任何进程,或者将此应用程序配置为在另一个端口上侦听。

解决端口被占用方法;

方法一:

win+r

输入netstat -ano

查找端口为8081的PID为556(你自己被占用的端口,我的是8081)

端口被占用问题:The Tomcat connector configured to listen on port 8081 failed to start._第1张图片

下一步:

tasklist | findstr "556"

下一步

taskkill/f /t /im java.exe    这一步是网上的说法是要杀死进程,执行失败但是后来看到另外一个方法让我恍然大悟

网上的方法执行的任务是杀死java.exe这个进程,但是每台电脑的配置环境都不一样,(这里我也不知道我自己语言组织得对不对望大神路过纠正)我看了看任务管理器是javaw.exe在占用8081这个端口所以杀死的应该是javaw.exe这个进程

所以执行命令为  taskkill/f /t /im javaw.exe

端口被占用问题:The Tomcat connector configured to listen on port 8081 failed to start._第2张图片

方法二:

跟方法一的步骤一一样:先查找除对应被占用端口的PID

然后打开任务管理器,查找对应PID进程,结束任务即可

方法三:简单粗暴

打开application.properties更改端口,用一个没被占用的端口 server.port=8080

端口被占用问题:The Tomcat connector configured to listen on port 8081 failed to start._第3张图片

 

你可能感兴趣的:(杂七杂八记)