出现错误:没有 org.springframework.boot.info.BuildProperties 类型的合格 bean

52h*_*erz 8 spring-boot

我有一个带有 spring-web 的项目。但这不是一个 spring-boot 项目。当我运行该项目时,出现错误:No qualifying bean of type org.springframework.boot.info.BuildProperties。我该如何解决?

小智 10

看看将以下内容添加到您的 pom.xml (假设它是一个 Maven 项目)是否有帮助。

<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>
Run Code Online (Sandbox Code Playgroud)


小智 -1

org.springframework.boot:spring-boot如果您还没有依赖项,您可以尝试添加依赖项,然后声明一个BuildPropertiesbean:

@Bean
BuildProperties buildProperties() {
    return new BuildProperties();
}
Run Code Online (Sandbox Code Playgroud)