Spring 应用程序立即关闭

Spring application shutting down immediately

我刚开始学习 Spring,所以我通过将 Spring-boot 版本设置为 2.0,从 https://start.spring.io/ 获得了样板 spring-boot 项目。 4、Java version 到 10 并添加 Web 作为依赖。我正在使用 STS-3.9.5.RELEASE 作为我的 ide。我 运行 这个项目作为一个 java 应用程序,这是我得到的控制台输出,

2018-08-21 13:04:55.009  INFO 8352 --- [           main] com.globalmatics.bike.BikeApplication    : Starting BikeApplication on LAPTOP-MO8TLAE6 with PID 8352 (D:\Education\spring-tool-suite-3.9.5.RELEASE-e4.8.0-win32-x86_64\workspace\bike\demo\target\classes started by Rajesh Raghunathan in D:\Education\spring-tool-suite-3.9.5.RELEASE-e4.8.0-win32-x86_64\workspace\bike\demo)
2018-08-21 13:04:55.014  INFO 8352 --- [           main] com.globalmatics.bike.BikeApplication    : No active profile set, falling back to default profiles: default
2018-08-21 13:04:55.062  INFO 8352 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@6f10d5b6: startup date [Tue Aug 21 13:04:55 IST 2018]; root of context hierarchy
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils (file:/C:/Users/Rajesh%20Raghunathan/.m2/repository/org/springframework/spring-core/5.0.8.RELEASE/spring-core-5.0.8.RELEASE.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of org.springframework.cglib.core.ReflectUtils
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
2018-08-21 13:04:55.938  INFO 8352 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2018-08-21 13:04:55.952  INFO 8352 --- [           main] com.globalmatics.bike.BikeApplication    : Started BikeApplication in 1.229 seconds (JVM running for 1.598)
2018-08-21 13:04:55.955  INFO 8352 --- [       Thread-1] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@6f10d5b6: startup date [Tue Aug 21 13:04:55 IST 2018]; root of context hierarchy
2018-08-21 13:04:55.957  INFO 8352 --- [       Thread-1] o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans on shutdown

我检查了 pom,发现它有 spring-boot-starter-web 依赖项,我知道这个依赖项负责启动 tomcat 服务器,但不确定为什么它不起作用。

编辑:我再次下载了项目和 运行 mvn clean install 命令,并通过 powershell 直接 运行 jar。仍然出现相同的错误。然而,这次我注意到这个控制台输出,

[ERROR] error reading C:\Users\Rajesh Raghunathan\.m2\repository\org\apache\tomcat\embed\tomcat-embed-core.5.32\tomcat-embed-core-8.5.32.jar; ZipFile invalid LOC header (bad signature)

看起来您的文件 tomcat-embed-core-8.5.32.jar 实际上已损坏。 试试怎么样

mvn clean install -U

强制重新加载?