我在启动 Restful Spring Boot 应用程序时遇到问题。在看到错误堆栈跟踪时,我可以看到一些与 jetty 相关的异常。
我可以看到下面的日志。
Started o.s.b.c.e.j.JettyEmbeddedWebAppContext@26586b74{/,file:/C:/Windows/Temp/jetty-docbase.8144885224534920922.8080/,AVAILABLE}
我确实检查了C:/windows/Temp
,但找不到jetty-docbase.8144885224534920922.8080
如果有人能帮助我解决这个问题,那就太好了。我如何创建该文件以便 jetty 能够识别它?
下面是完整的堆栈跟踪。
mo.e.jetty.server.handler.ContextHandler; Started o.s.b.c.e.j.JettyEmbeddedWebAppContext@26586b74{/,file:/C:/Windows/Temp/jetty-docbase.8144885224534920922.8080/,AVAILABLE}
morg.eclipse.jetty.server.Server Started @7364ms
mationConfigEmbeddedWebApplicationContext Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'configController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.lewis.web.app.operations.dashboard.models.BuildInformation com.lewis.web.app.operations.dashboard.controllers.ConfigController.buildInformation; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'buildInformationProperties': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.lang.String com.lewis.web.app.operations.dashboard.models.BuildInformationProperties.version; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'build.version' in string value "${build.version}"
mo.e.jetty.server.handler.ContextHandle Stopped o.s.b.c.e.j.JettyEmbeddedWebAppContext@26586b74{/,file:/C:/Windows/Temp/jetty-docbase.8144885224534920922.8080/,UNAVAILABLE}
mo.s.boot.SpringApplication Application startup failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'configController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.lewis.web.app.operations.dashboard.models.BuildInformation com.lewis.web.app.operations.dashboard.controllers.ConfigController.buildInformation; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'buildInformationProperties': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.lang.String com.lewis.web.app.operations.dashboard.models.BuildInformationProperties.version; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'build.version' in string value "${build.version}"
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
at com.lewis.web.app.Application.main(Application.java:25)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.lewis.web.app.operations.dashboard.models.BuildInformation com.lewis.web.app.operations.dashboard.controllers.ConfigController.buildInformation; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'buildInformationProperties': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.lang.String com.lewis.web.app.operations.dashboard.models.BuildInformationProperties.version; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'build.version' in string value "${build.version}"
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:573)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
... 15 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'buildInformationProperties': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.lang.String com.lewis.web.app.operations.dashboard.models.BuildInformationProperties.version; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'build.version' in string value "${build.version}"
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
... 17 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.lang.String com.lewis.web.app.operations.dashboard.models.BuildInformationProperties.version; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'build.version' in string value "${build.version}"
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:573)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
... 37 common frames omitted
Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'build.version' in string value "${build.version}"
at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:174)
提前非常感谢...
最佳答案
您的实际异常是:
Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'build.version' in string value "${build.version}"
这意味着 Spring 应用程序无法创建上下文并启动,因为无法创建某些 Bean,因为它无法解析某些所需的 Autowiring 变量,在您的情况下它是一个 build.version
。您可以尝试将此变量添加为命令行参数或将其作为属性添加到 application.properies
文件中。或者您可以找到该 bean(它的名称是 buildInformationProperties
,其中该值应该是 autowird,并尝试找出为什么默认情况下没有它。
关于java - springboot 应用程序未启动 - 错误(已停止 o.s.b.c.e.j.JettyEmbeddedWebAppContext),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37974913/