An alternative to @Value annotation in static function

Viewed 24457

It's not possible to use @Value on a static variable.

@Value("${some.value}")
static private int someValue;

static public void useValue() {
    System.out.println(someValue);
}

When I do this, 0 is printed. So what is a good alternative to this?

4 Answers

The following codes work for me,

public class MappingUtils {

  private static String productTypeList;

  @Value("${productType-list}")
  public void setProductTypeList(String productTypeList) {
    MappingUtils.getProductTypeList = productTypeList;
  }
}
Related