import org.springframework.beans.factory.annotation.Value;  
import org.springframework.stereotype.Component;  
  
@Component  
public class GlobalValue {  
    // @Value("${mongodb.db}") 这种方式无法给静态变量赋值
    public static String DATABASE;  

    @Value("${mongodb.db}")  
    public void setDatabase(String db) {  
        DATABASE = db;  
    }  
}

 

相关文章:

  • 2021-04-28
  • 2021-12-20
  • 2022-12-23
  • 2022-03-08
  • 2022-12-23
  • 2021-07-12
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-09
  • 2022-12-23
  • 2021-07-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案