启动Spring引导时,应用程序卡住,SpringApplication.run不返回。
@Configuration
@ComponentScan
@EnableAutoConfiguration
public class AccountServiceApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
ConfigurableApplicationContext context = SpringApplication.run(AccountServiceApplication.class, args);
System.out.println("----------------------------- I'm done -------------------------");
}
}
我可以看到Spring创建了所有的bean,但是它永远不会返回,尽管嵌入式tomcat是从9000开始的,它没有监听
class org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory's object [after] tomcatEmbeddedServletContainerFactory
[05/16/19 06:17:44:044 IST] INFO tomcat.TomcatEmbeddedServletContainer: : Tomcat initialized with port(s): 9000 (http)
May 16, 2019 6:17:44 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-nio-9000"]
May 16, 2019 6:17:44 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service [Tomcat]
Trying 127.0.0.1...
Connection failed: Connection refused
Trying ::1...
telnet: Unable to connect to remote host: Connection refused
创建JMS连接后,应用程序将永远卡住。
class org.springframework.expression.spel.support.StandardEvaluationContext's object [after] integrationEvaluationContext
class org.springframework.integration.handler.LoggingHandler's object [after] _org.springframework.integration.errorLogger.handler
class org.springframework.integration.config.ConsumerEndpointFactoryBean's object [before]_org.springframework.integration.errorLogger
class org.springframework.integration.config.ConsumerEndpointFactoryBean's object [after] _org.springframework.integration.errorLogger
class org.springframework.integration.config.IdGeneratorConfigurer's object [before]org.springframework.integration.config.IdGeneratorConfigurer#0
class org.springframework.integration.config.IdGeneratorConfigurer's object [after] org.springframework.integration.config.IdGeneratorConfigurer#0
[05/16/19 05:58:02:002 IST] INFO annotation.AnnotationMBeanExporter: : Registering beans for JMX exposure on startup
class org.springframework.expression.spel.support.StandardEvaluationContext's object [after] integrationEvaluationContext
[05/16/19 05:58:02:002 IST] INFO support.DefaultLifecycleProcessor: : Starting beans in phase 0
[05/16/19 05:58:02:002 IST] INFO endpoint.EventDrivenConsumer: : Adding {logging-channel-adapter:_org.springframework.integration.errorLogger} as a subscriber to the 'errorChannel' channel
[05/16/19 05:58:02:002 IST] INFO channel.PublishSubscribeChannel: : Channel 'application:9000.errorChannel' has 1 subscriber(s).
[05/16/19 05:58:02:002 IST] INFO endpoint.EventDrivenConsumer: : started _org.springframework.integration.errorLogger
[05/16/19 05:58:02:002 IST] INFO support.DefaultLifecycleProcessor: : Starting beans in phase 2147483647
[05/16/19 05:58:02:002 IST] INFO connection.CachingConnectionFactory: : Established shared JMS Connection: ActiveMQConnection {id=ID:SDSD121SFSSDF.local-54305-1557966482134-1:1,clientId=null,started=false}
关于如何调试它的任何指针?
答案 0 :(得分:1)
在您的应用程序中,可能存在一个带有无限循环的线程。您的应用程序启动失败。并且该线程不退出。该过程仍然存在。看起来好像启动成功。
答案 1 :(得分:1)
在这种情况下可能会有所帮助的常见做法是“ catch the lion in the desert / binary search”找出问题的原因。
尝试注释掉应用程序的一半,直到达到应用程序启动没有问题的程度。然后,您将能够确定有问题的代码/部分。
答案 2 :(得分:0)
我也被困在:
INFO support.DefaultLifecycleProcessor: : Starting beans in phase X
这是因为在@RestController类中,我使@GetMapping方法返回了一个@Entity,而该实体应该是DTO。