java - Spring WAR 不创建 BuildProperties Bean

标签 java spring spring-boot gradle spring-boot-actuator

我正在对我的一个项目工件进行一些转换,以便我们可以使用 spring boot 运行它,而不是仅部署到 jboss,以及添加执行器。这非常顺利,但是在使一切都在 spring boot 上运行的过程中,我破坏了将 WAR 部署到 jboss 的能力。

具体来说,我已将 BuildInformation 添加到我们的部署信息端点。根据我对执行器和 build-info.properties 创建的理解,以及我在试图找到其他有此问题的人时发现的每一个谷歌结果,我目前正在做的应该是在职的。我有

    compile 'org.springframework.boot:spring-boot-starter-actuator'

在我的平台级项目的 gradle 的 subprojects 部分(以及我们使用的所有其他 spring-boot 依赖项)。 springBoot 任务配置为运行 buildInfo()。生成的 WAR 文件在 /WEB-INF/classes/META-INF/ 下具有 build-info.properties 文件。一切似乎都按照预期的方式组合在一起。然而:

13:09:59,517 ERROR [org.springframework.web.servlet.DispatcherServlet] (ServerService Thread Pool -- 53) Context initialization failed: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'pingController' defined in VFS resource ["<snip>/PingController.class"]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.boot.info.BuildProperties' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}

关于我应该看哪里的任何想法?

最佳答案

尽管带有 main 方法的类被 @SpringBootApplication 注释,但在打包到 WAR 中时仍未启用自动配置。我在我的根 @Configuration 类上添加了 @EnableAutoConfiguration 并且一切正常。

关于java - Spring WAR 不创建 BuildProperties Bean,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47800298/

相关文章:

java - 如何使用 Commons CLI 传递(和获取后)参数数组?

java - 通过 spring 作为单例 bean 创建时清晰的 GUI 表单

java - 如何在 spring boot 应用程序的 .log 文件中写入 stdout 语句

java - Spring Boot 中的每个@RequestBody 都需要一个单独的对象吗

java - Jaspersoft Studio - 如何创建自定义函数来增加/减少 barChart 中条形的宽度?

java - Apache Flink (v1.6.0) 验证 Elasticsearch Sink (v6.4)

java - 日期计算 Java 赋值

SpringIntegration : Service-Activator not invoking method

java - 再次使用 Autowire Bean 还是使用 getter?

java - 使用带有 Springs 的外部属性文件作为 init.d 服务