Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
This class is initiated at the start of the application and the values of the properties injected are logged in the terminal
package com.spring.injectprops;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import java.util.logging.Logger;
public class MainClass implements CommandLineRunner {
private String baseUrl;
private String username;
private String password;
private static final Logger LOGGER = Logger.getLogger(MainClass.class.getName());
public void run(String... args) throws Exception {"The value of the baseUrl is : " + baseUrl);"The value of the username is : " + username);"The value of the password is : " + password);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment