Spring WAR不会创建BuildProperties Bean

时间:2017-12-13 18:57:41

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

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

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

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

在我的subprojects部分gradle中,用于我的平台级项目(以及我们使用的所有其他spring-boot依赖项)。 springBoot任务配置为运行buildInfo()。生成的WAR文件在build-info.properties下有/WEB-INF/classes/META-INF/个文件。似乎所有东西都应该完全像它应该的那样组合在一起。然而:

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: {}

有关我应该在哪里寻找的想法吗?

2 个答案:

答案 0 :(得分:2)

尽管main方法的类使用@SpringBootApplication进行了注释,但在打包到WAR时仍未启用自动配置。我在我的根@EnableAutoConfiguration课程中添加了@Configuration,一切都结束了。

答案 1 :(得分:0)

如果有人发现了这个问题,我的问题是,当IDE构建代码时,我没有build属性,但是如果我从控制台或Spring Intellij的maven工具窗口运行“ maven install”将创建BuildProperties构建。我怀疑IDE可能会采用一些快捷方式。例如,构建时间戳记停留在最后的“ true”构建。

使用Intellij,通过单击视图>工具窗口> Maven来显示Maven面板。然后打开生命周期,然后右键单击要运行的Maven目标(最常安装)并运行

相关问题