简体   繁体   中英

Spring WAR doesn't create BuildProperties Bean

I'm doing a bit of a conversion on one of my project artifacts so that we can run it with spring boot instead of only deploying to jboss, as well as adding actuators. This has gone excellently, but in the process of making everything work on spring boot, I've broken the ability to deploy the WAR to jboss.

Specifically, I've added BuildInformation to our deployment information endpoint. Based on my understanding of actuators and build-info.properties creation, as well as literally every google result I've found while trying to find someone else with this problem, what I'm doing currently should be working. I have

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

in my subprojects section of gradle for my platform-level project (along with every other spring-boot dependency we use). The springBoot task is configured to run buildInfo() . The resultant WAR file has the build-info.properties file under /WEB-INF/classes/META-INF/ . Everything appears to be put together exactly like it's supposed to be. And yet:

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

Any thoughts on where I should be looking?

Despite the class with the main method being annotated with @SpringBootApplication , autoconfigure still wasn't being enabled when packaged into a WAR. I added @EnableAutoConfiguration on my root @Configuration class and everything ended up working.

If anyone found this, my issue is that when the IDE is building the code, I don't have the a build properties but if I run 'maven install' from the console or from a maven tool windows in Intellij, Spring will create the BuildProperties build. I suspect the IDE might take some shortcuts. For example, the build timestamp stays at the last "true" build.

Using Intellij, Maven panel is displayed by clicking at View > Tools Windows > Maven . Then open lifecycle and right click the maven goal you wanna run (install most often) and run

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM