简体   繁体   English

Spring 在 Eclipse 上输出 logo 和版本后启动应用程序突然停止

[英]Spring Boot application suddenly stops after outputing logo and version on Eclipse

When I execute Run As -> Java application my Spring Boot application class on Eclipse, I get Spring Boot logo and version in logs but it halts and stops after few seconds:当我在 Eclipse 上执行 Run As -> Java application my Spring Boot application class 时,我在日志中得到 Spring Boot 徽标和版本,但它会在几秒钟后暂停并停止:

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/

Spring version: 1.5.9.RELEASE

There are no errors in console.控制台中没有错误。

Tried but didn't help:尝试但没有帮助:

  • Project -> Clean, project refresh on Eclipse Project -> Clean,Eclipse 上的项目刷新
  • gradle clean , build , eclipse from command line gradle clean , build , eclipse从命令行
  • Deleted and imported project from git again再次从 git 删除并导入项目
  • Restart Eclipse重启 Eclipse

Tried solutions from related SO threads:来自相关 SO 线程的尝试解决方案:

Also:还:

  • If I run tests from Eclipse, they pass successfully.如果我从 Eclipse 运行测试,它们会成功通过。
  • Other Spring Boot apps run well on Eclipse.其他 Spring 引导应用程序在 Eclipse 上运行良好。
  • When I try to run application from command line with gradle bootRun , it runs smoothly.当我尝试使用gradle bootRun从命令行运行应用程序时,它运行顺利。

Why does it happen?为什么会这样? How to solve it?如何解决?

Deleted logback.xml from src/main/resources and logback-test.xml from src/test/resources and it worked.src/main/resources中删除logback.xml ,从src/test/resources中删除了logback-test.xml ,它起作用了。

In my case It was fixed when added the spring boot web dependency在我的例子中,它在添加 spring boot web 依赖项时得到修复

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>

Spring Boot is still working, just there is no output in the console after logo. Spring Boot 还在工作,只是在 logo 之后控制台没有任何输出。 Server will startup if there are no other issues.如果没有其他问题,服务器将启动。

In my case Spring Boot console stopped logging after i renamed application.properties into core.properties (that file is referred in logback.xml)在我的例子中,Spring Boot 控制台在我将 application.properties 重命名为 core.properties 后停止记录(该文件在 logback.xml 中引用)

<define name="internalFile" class="ch.qos.logback.core.property.ResourceExistsPropertyDefiner">
    <resource>application.properties</resource>
</define>

After updating the resource tag, console output was back.更新资源标签后,控制台输出又回来了。

in my case the reason was that I was using an alpha release of sl4j.在我的例子中,原因是我使用的是 sl4j 的 alpha 版本。 When i replaced it with an older one I was able to start the spring boot application.当我用旧的替换它时,我能够启动 spring boot 应用程序。

If the answers above are not satisfactory the issue in my case was that I was including dependency with its own slf4j setup, that got in clash with Spring Boot's one (old vs. new).如果上面的答案不令人满意,在我的案例中,问题是我将依赖包含在它自己的 slf4j 设置中,这与 Spring Boot 的设置(旧与新)发生冲突。

The problem was that the dependency was accidentally built as fat-jar.问题是依赖项被意外地构建为 fat-jar。

I had this issue from upgrading the slf4j-api dependency from 1.X to 2.0.6 .我在将slf4j-api依赖项从1.X升级到2.0.6时遇到了这个问题。 We were able to resolve by adding slf4j-simple:2.0.6 dependency as well.我们也能够通过添加slf4j-simple:2.0.6依赖项来解决。 The slf4j patch notes for version 2.0 go over this topic here .有关此主题的2.0版 slf4j 补丁说明 go 在这里 Spring hanging on the logo appears to be an additional side effect. Spring 挂在徽标上似乎是一个额外的副作用。

slf4j-api version slf4j-api版本 slf4j-simple version slf4j-简单版 Result结果 Explanation解释
2.0.x 2.0.x 2.0.x 2.0.x OK好的 Same version for slf4j-api and provider slf4j-api 和提供者的相同版本
1.7.x 1.7.x 2.0.x 2.0.x no bindings can be found warning message找不到绑定警告消息 2.0.x providers do not act as 1.7.x/1.6.x compatible bindings 2.0.x 提供程序不充当 1.7.x/1.6.x 兼容绑定
2.0.x 2.0.x 1.7.x 1.7.x no providers can be found warning message找不到提供者警告消息 slf4j-api 2.0.x will no longer search for StaticLoggerBinding slf4j-api 2.0.x 将不再搜索 StaticLoggerBinding

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM