I am working in a micro services based architecture where each service has dependency of base jar.
So I want to print BUILD info(project version and build time) at the Spring Boot application startup.
Please suggest a way to make the changes only in base jar .
for individual service My code goes like this:
public class PaymentApplication extends SpringBootServletInitializer {
@Autowired
Optional<BuildProperties> buildProperties;
private static final Logger LOGGER = LoggerFactory.getLogger(PaymentApplication .class);
public static void main(String[] args) throws Exception {
ConfigurableApplicationContext appContext = SpringApplication.run(PaymentApplication .class, args);
appContext.registerShutdownHook();
}
@PostConstruct
private void logVersion() {
if(buildProperties.isPresent()) {
LOGGER.info("### BUILD_INFO=[version={}, buildTime={}]",buildProperties.get().getVersion(),buildProperties.get().getTime());
}
}
plugin in pom.xml
<!-- Build Info plug-in -->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<id>build-info</id>
<goals>
<goal>build-info</goal>
</goals>
</execution>
</executions>
</plugin>