简体   繁体   English

Maven Spring Boot应用程序卡住

[英]Maven Spring Boot application stuck

I have created a sample Spring Boot application which i can Run with Run as Spring Boot App option in STS. 我创建了一个示例Spring Boot应用程序,该应用程序可以与STS中的“以Spring Boot App运行”选项一起运行。 I can also run Junit tests with Run as Junit Option without any issue. 我也可以使用“以Junit选项运行”来运行Junit测试,而不会出现任何问题。

But when i try to package my application with Maven using Run as Maven Build option, application just stuck at some point always. 但是,当我尝试使用“以Maven生成方式运行”选项将应用程序与Maven打包时,应用程序总是停留在某个时刻。

I have below piece of code at starting level. 我在入门级下面有一段代码。

public static void main(String[] args) {
    SpringApplication.run(Application.class, args);
}
@Override
public void run(String... args) throws Exception {
    Scanner scan = new Scanner(System.in);

    String name = scan.next();// It just stuck here especially when i use run as maven build

    Double balance = scan.nextDouble();
    Card card = new Card(name, balance);

    scan.close();

My console looks like stuck here 我的控制台看起来像卡在这里

    2018-03-11 00:39:58.619  INFO 22835 --- [           main] c.a.o.t.daoImpl.test.JourneyDAOImplTest  : Starting JourneyDAOImplTest on localhost.localdomain with PID 22835 (started by root in /root/Documents/workspace-sts-3.9.0.RELEASE/oystercard)
2018-03-11 00:39:58.629  INFO 22835 --- [           main] c.a.o.t.daoImpl.test.JourneyDAOImplTest  : No active profile set, falling back to default profiles: default
2018-03-11 00:39:58.931  INFO 22835 --- [           main] o.s.w.c.s.GenericWebApplicationContext   : Refreshing org.springframework.web.context.support.GenericWebApplicationContext@6c1a5b54: startup date [Sun Mar 11 00:39:58 IST 2018]; root of context hierarchy
2018-03-11 00:40:04.630  INFO 22835 --- [           main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.web.context.support.GenericWebApplicationContext@6c1a5b54: startup date [Sun Mar 11 00:39:58 IST 2018]; root of context hierarchy
2018-03-11 00:40:04.991  INFO 22835 --- [           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-03-11 00:40:04.995  INFO 22835 --- [           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-03-11 00:40:05.155  INFO 22835 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-03-11 00:40:05.177  INFO 22835 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-03-11 00:40:05.427  INFO 22835 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-03-11 00:40:05.942  INFO 22835 --- [           main] c.a.o.t.daoImpl.test.JourneyDAOImplTest  : Started JourneyDAOImplTest in 8.48 seconds (JVM running for 12.679)

I am only expecting two values from Scan . 我只期望Scan两个值。 where i Have given many values to just show the application stuck at this point. 在这里我给出了很多值,只是表明应用程序在这一点上卡住了。

2018-03-11 08:00:50.876  INFO 18520 --- [           main] c.a.o.t.daoImpl.test.JourneyDAOImplTest  : Starting JourneyDAOImplTest on localhost.localdomain with PID 18520 (started by root in /root/Documents/workspace-sts-3.9.0.RELEASE/oystercard)
2018-03-11 08:00:50.880  INFO 18520 --- [           main] c.a.o.t.daoImpl.test.JourneyDAOImplTest  : No active profile set, falling back to default profiles: default
2018-03-11 08:00:51.105  INFO 18520 --- [           main] o.s.w.c.s.GenericWebApplicationContext   : Refreshing org.springframework.web.context.support.GenericWebApplicationContext@6c1a5b54: startup date [Sun Mar 11 08:00:51 IST 2018]; root of context hierarchy
2018-03-11 08:00:59.383  INFO 18520 --- [           main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.web.context.support.GenericWebApplicationContext@6c1a5b54: startup date [Sun Mar 11 08:00:51 IST 2018]; root of context hierarchy
2018-03-11 08:00:59.739  INFO 18520 --- [           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-03-11 08:00:59.742  INFO 18520 --- [           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-03-11 08:00:59.880  INFO 18520 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-03-11 08:00:59.881  INFO 18520 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-03-11 08:01:00.053  INFO 18520 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-03-11 08:01:02.014  INFO 18520 --- [           main] c.a.o.t.daoImpl.test.JourneyDAOImplTest  : Started JourneyDAOImplTest in 12.566 seconds (JVM running for 18.154)

**Rajesh
30.0
30.0
Rajesh
Rajesh
30.0
fdsfdsfdsjfds
46548768672**

UPDATE: When i ran mvn spring-boot:run , It works fine. 更新:当我运行mvn spring-boot:run ,它工作正常。 But If i ran using mvn clean install spring-boot:run , it stuck in the middle Any Help? 但是,如果我使用mvn clean install spring-boot:run ,它停在中间有帮助吗?

The application is stuck because it is waiting for input data in scan.next() method call. 该应用程序被阻塞,因为它正在等待scan.next()方法调用中的输入数据。

As per Java documentation : 根据Java文档

This method may block while waiting for input to scan, even if a previous invocation of hasNext() returned true. 即使先前调用hasNext()返回true,此方法也可能在等待输入扫描时阻塞。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Spring Boot应用程序-Maven问题 - Spring Boot Application - Maven Issue 带有 Spring Boot 应用程序的 Docker 卡在 RaspberryPi 上的 AnnotationConfigServletWebServerApplicationContext - Docker with Spring Boot application stuck at AnnotationConfigServletWebServerApplicationContext on RaspberryPi Spring 引导应用程序在运行时卡住 - Spring boot application is getting stuck while running Spring Boot 初始化未完成 [应用卡住] - Spring Boot initialization not completing [Application stuck] 使用Java 9和Maven的Spring Boot应用程序编译失败 - compilation failure for spring boot application with java 9 and maven Maven 验证 Spring Boot 应用程序类的 ClassNotFoundException - Maven verify ClassNotFoundException for class of Spring Boot application spring 引导应用程序如何受 maven 依赖项影响? - How is the spring boot application affected by the maven dependencies? Spring Boot 应用程序卡在:Initializing Spring DispatcherServlet &#39;dispatcherServlet&#39; - Spring Boot application stuck at: Initializing Spring DispatcherServlet 'dispatcherServlet' Spring Boot 应用程序启动时卡住了加载休眠文件 - Spring boot application startup stuck loading hibernate files Spring 启动应用程序卡在事务 requried_new - Spring boot application stuck with Transaction requried_new
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM