簡體   English   中英

Spring WAR 不會創建 BuildProperties Bean

[英]Spring WAR doesn't create BuildProperties Bean

我正在對我的一個項目工件進行一些轉換,以便我們可以使用 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: {}

關於我應該去哪里尋找的任何想法?

盡管使用@SpringBootApplication注釋了main方法的類,但在打包到 WAR 時仍然沒有啟用自動配置。 我在我的根@Configuration類上添加了@EnableAutoConfiguration ,一切都結束了。

如果有人發現了這一點,我的問題是當 IDE 構建代碼時,我沒有構建屬性,但是如果我從控制台或 Intellij 中的 maven 工具窗口運行“maven install”,Spring 將創建BuildProperties 構建。 我懷疑 IDE 可能會走一些捷徑。 例如,構建時間戳保持在最后一個“真實”構建。

使用 Intellij,通過單擊 View > Tools Windows > Maven 顯示 Maven 面板。 然后打開生命周期並右鍵單擊您要運行的 Maven 目標(最常安裝)並運行

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM