IntelliJ에서 실행시 build-info.properties 생성되지 않을 때

2023. 10. 11. 21:53plming/Java-Spring Boot

IntelliJ에서 spring boot, maven 환경에서 실행 시

실행되지 못하고, 아래같은 형태의 메시지를 표시하고 죽는다면...

Field ... in ... required a bean of type 'org.springframework.boot.info.BuildProperties' 
that could not be found.

The injection point has the following annotations:
	- @org.springframework.beans.factory.annotation.Autowired(required=true)

The following candidates were found but could not be injected:
	- Bean method 'buildProperties' in 'ProjectInfoAutoConfiguration' not loaded because
      @ConditionalOnResource did not find resource 
      '${spring.info.build.location:classpath:META-INF/build-info.properties}'

\target\classes\META-INF\build-info.properties 가 생성되지 않아서이다.

 

 

pom.xml 파일에

아래 내용만 추가해주면 된다.

<project>
  ...
  <build>
    ...
    <plugins>
      ...
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <version>2.0.6.RELEASE</version>
        <executions>
          <execution>
            <goals>
              <goal>build-info</goal>
            </goals>
            <configuration>
              <additionalProperties>
                <encoding.source>UTF-8</encoding.source>
                <encoding.reporting>UTF-8</encoding.reporting>
                <java.source>${maven.compiler.source}</java.source>
                <java.target>${maven.compiler.target}</java.target>
              </additionalProperties>
            </configuration>
          </execution>
        </executions>

 

 

또 다른 방법은

mvn clean install

명령으로도 생성된다.  (1회성)