52herz
52herz

Reputation: 105

Get Error: No qualifying bean of type org.springframework.boot.info.BuildProperties

I have a project with spring-web. But it isn't a spring-boot project. When I run the project, I get an error: No qualifying bean of type org.springframework.boot.info.BuildProperties. How can I solve it?

Upvotes: 10

Views: 19103

Answers (6)

Oscar Nascimento
Oscar Nascimento

Reputation: 17

A solution is to add to your MAIN class (eg. MainApplication)

@Bean
BuildProperties buildProperties() {
    return new BuildProperties(new Properties());
}

Upvotes: -1

Faisal Khan
Faisal Khan

Reputation: 242

If you already have build-info goal in your pom.xml and you are trying to run your project from Intellij or another IDE, you might face this issue.

The solution is to simply run mvn package which will generate the build-info.properties needed for the startup.

Upvotes: 6

jdawg73
jdawg73

Reputation: 96

This could be happening for any number of reasons. For me, it happened after I upgraded IntelliJ. The build-info goal was already in the POM. My solution (which is also a comment on the most highly-voted answer) was to simply do a maven clean. Then everything was happy again.

Upvotes: 4

Joel Shemtov
Joel Shemtov

Reputation: 3078

What worked for me was an advice from my colleague to place the build-info properties where eclipse expects it:

mkdir -p ./bin/main/META-INF/

cp ./build/resources/main/META-INF/build-info.properties ./bin/main/META-INF/build-info.properties

Upvotes: 0

Janani
Janani

Reputation: 121

See if adding the below to your pom.xml (assuming it's a maven project) helps.

<build>
        <finalName>{NAME_YOUR_PROJECT}</finalName>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>build-info</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

Upvotes: 12

rookieeee
rookieeee

Reputation: 67

You can try add a dependency on org.springframework.boot:spring-boot if you do not have one already and then declare a BuildProperties bean:

@Bean
BuildProperties buildProperties() {
    return new BuildProperties();
}

Upvotes: 0

Related Questions