출처 : https://www.mkyong.com/spring/spring-inject-a-value-into-static-variables/


@Component 를 꼭 써줘야 한다



import org.springframework.beans.factory.annotation.Value;

import org.springframework.stereotype.Component;

 

@Component

public class GlobalValue {

 

    public static String DATABASE;

 

    @Value("${mongodb.db}")

    public void setDatabase(String db) {

        DATABASE = db;

    }

}


Posted by motolies
,