Spring boot启动遇到问题

  本主出现启动错误查找到博客解决问题,纯属笔记,原文出处:Spring Boot几种启动问题的解决方案,致谢。

1.启动Spring报错:s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext

Q:新建了一个Springboot出现一下错误:

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.0.4.RELEASE)

2018-08-28 13:52:39.691  INFO 10464 --- [           main] com.cs.CsTestMongo1Application           : Starting CsTestMongo1Application on BZ5SVMTP2 with PID 10464 (D:\workspace\salesPromotion\cs-test-mongo-1\target\classes started by csh10393 in D:\workspace\salesPromotion\cs-test-mongo-1)
2018-08-28 13:52:39.693  INFO 10464 --- [           main] com.cs.CsTestMongo1Application           : No active profile set, falling back to default profiles: default
2018-08-28 13:52:39.723  INFO 10464 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@279ad2e3: startup date [Tue Aug 28 13:52:39 CST 2018]; root of context hierarchy
2018-08-28 13:52:40.076  INFO 10464 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2018-08-28 13:52:40.086  INFO 10464 --- [           main] com.cs.CsTestMongo1Application           : Started CsTestMongo1Application in 0.581 seconds (JVM running for 1.06)
2018-08-28 13:52:40.088  INFO 10464 --- [       Thread-3] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@279ad2e3: startup date [Tue Aug 28 13:52:39 CST 2018]; root of context hierarchy
2018-08-28 13:52:40.090  INFO 10464 --- [       Thread-3] o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans on shutdown

原因:项目中没有添加spring-boot-starter-web模块依赖,在启动 Application 运行过程中会出现这个错误。

解决途径:

 <!-- Spring boot 核心web-->
 <dependency>
     <groupId>org.springframework.boot</groupId>
     <artifactId>spring-boot-starter-web</artifactId>
 </dependency>

2.出现如下错误:Failed to start component [Connector[HTTP/1.1-8080]]

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.0.4.RELEASE)

2018-08-28 14:09:30.611  INFO 9076 --- [           main] com.cs.CsTestMongoApplication            : Starting CsTestMongoApplication on BZ5SVMTP2 with PID 9076 (D:\workspace\salesPromotion\cs-test-mongo\target\classes started by csh10393 in D:\workspace\salesPromotion\cs-test-mongo)
2018-08-28 14:09:30.613  INFO 9076 --- [           main] com.cs.CsTestMongoApplication            : No active profile set, falling back to default profiles: default
2018-08-28 14:09:30.652  INFO 9076 --- [           main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@5ef60048: startup date [Tue Aug 28 14:09:30 CST 2018]; root of context hierarchy
2018-08-28 14:09:31.443  INFO 9076 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2018-08-28 14:09:31.459  INFO 9076 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2018-08-28 14:09:31.459  INFO 9076 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.32
2018-08-28 14:09:31.462  INFO 9076 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener   : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [C:\Program Files\Java\jdk1.8.0_112\bin;C:\windows\Sun\Java\bin;C:\windows\system32;C:\windows;C:\ProgramData\Oracle\Java\javapath;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Java\jdk1.8.0_112\bin;C:\Program Files\Java\jdk1.8.0_112\jre\bin;C:\Program Files\MySQL\MySQL Server 8.0\bin;C:\Users\csh10393\AppData\Local\Microsoft\WindowsApps;D:\Program Files\git\Git\cmd;.]
2018-08-28 14:09:31.551  INFO 9076 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2018-08-28 14:09:31.551  INFO 9076 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 902 ms
2018-08-28 14:09:31.611  INFO 9076 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Servlet dispatcherServlet mapped to [/]
2018-08-28 14:09:31.614  INFO 9076 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-08-28 14:09:31.614  INFO 9076 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-08-28 14:09:31.614  INFO 9076 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-08-28 14:09:31.614  INFO 9076 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2018-08-28 14:09:31.698  INFO 9076 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-08-28 14:09:31.857  INFO 9076 --- [           main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@5ef60048: startup date [Tue Aug 28 14:09:30 CST 2018]; root of context hierarchy
2018-08-28 14:09:31.898  INFO 9076 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2018-08-28 14:09:31.899  INFO 9076 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2018-08-28 14:09:31.916  INFO 9076 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-08-28 14:09:31.920  INFO 9076 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-08-28 14:09:32.194  INFO 9076 --- [           main] org.mongodb.driver.cluster               : Cluster created with settings {hosts=[10.88.27.91:27017], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
2018-08-28 14:09:32.352  INFO 9076 --- [.88.27.91:27017] org.mongodb.driver.connection            : Opened connection [connectionId{localValue:1, serverValue:2842}] to 10.88.27.91:27017
2018-08-28 14:09:32.354  INFO 9076 --- [.88.27.91:27017] org.mongodb.driver.cluster               : Monitor thread successfully connected to server with description ServerDescription{address=10.88.27.91:27017, type=REPLICA_SET_PRIMARY, state=CONNECTED, ok=true, version=ServerVersion{versionList=[3, 4, 17]}, minWireVersion=0, maxWireVersion=5, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=null, roundTripTimeNanos=1030094, setName='rswms4dev', canonicalAddress=10.88.27.91:27017, hosts=[10.88.27.91:27017, wms4-mongo-db01:27017, 10.88.27.92:27017], passives=[], arbiters=[], primary='10.88.27.91:27017', tagSet=TagSet{[]}, electionId=7fffffff0000000000000006, setVersion=3, lastWriteDate=Tue Aug 28 14:09:22 CST 2018, lastUpdateTimeNanos=706374722939516}
2018-08-28 14:09:32.444  INFO 9076 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2018-08-28 14:09:32.458 ERROR 9076 --- [           main] o.apache.catalina.core.StandardService   : Failed to start connector [Connector[HTTP/1.1-8080]]

org.apache.catalina.LifecycleException: Failed to start component [Connector[HTTP/1.1-8080]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167) ~[tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.apache.catalina.core.StandardService.addConnector(StandardService.java:225) ~[tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.addPreviouslyRemovedConnectors(TomcatWebServer.java:256) [spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
    at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.start(TomcatWebServer.java:198) [spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.startWebServer(ServletWebServerApplicationContext.java:300) [spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:162) [spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:553) [spring-context-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) [spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:762) [spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:398) [spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:330) [spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1258) [spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1246) [spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
    at com.cs.CsTestMongoApplication.main(CsTestMongoApplication.java:10) [classes/:na]
Caused by: org.apache.catalina.LifecycleException: Protocol handler start failed
    at org.apache.catalina.connector.Connector.startInternal(Connector.java:1020) ~[tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ~[tomcat-embed-core-8.5.32.jar:8.5.32]
    ... 13 common frames omitted
Caused by: java.net.BindException: Address already in use: bind
    at sun.nio.ch.Net.bind0(Native Method) ~[na:1.8.0_112]
    at sun.nio.ch.Net.bind(Net.java:433) ~[na:1.8.0_112]
    at sun.nio.ch.Net.bind(Net.java:425) ~[na:1.8.0_112]
    at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223) ~[na:1.8.0_112]
    at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74) ~[na:1.8.0_112]
    at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:210) ~[tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.apache.tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.java:1150) ~[tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java:591) ~[tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.apache.catalina.connector.Connector.startInternal(Connector.java:1018) ~[tomcat-embed-core-8.5.32.jar:8.5.32]
    ... 14 common frames omitted

2018-08-28 14:09:32.461  INFO 9076 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2018-08-28 14:09:32.467  INFO 9076 --- [           main] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-08-28 14:09:32.470 ERROR 9076 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

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

Description:

The Tomcat connector configured to listen on port 8080 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 8080, or configure this application to listen on another port.

2018-08-28 14:09:32.470  INFO 9076 --- [           main] ConfigServletWebServerApplicationContext : Closing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@5ef60048: startup date [Tue Aug 28 14:09:30 CST 2018]; root of context hierarchy
2018-08-28 14:09:32.473  INFO 9076 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans on shutdown

  原因:你自己把项目起了两遍,自己再瞅瞅。
  解决:关闭所有运行的项目,重新运行。

猜你喜欢

转载自blog.csdn.net/u010986518/article/details/82146747