I have a utility class to read the environment variables.
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
@Component
public final class PropertyUtil {
/** The system environment. */
private static Environment environment;
public static String getConfigProp(final String key) {
return environment.getProperty(key);
}
@Autowired
public void setEnvironment(Environment environment) {
PropertyUtil.environment = environment;
}
}
And I use it in one bean while initialization. The problem is that it runs file if I deploy the war file on tomcat but if I run the same application as a spring boot application from eclipse, it does not read the environment properties and the return values are therefore null.
Any idea what could be the cause of this problem?