import java.lang.reflect.Field;   

    static String url;
    public static void main(String[] agrs) throws Exception{
        Class<?> clazz = DBPool.class;
        Field fieldUrl = clazz.getDeclaredField("url");
        fieldUrl.setAccessible(true);//只有这里设置为true才可以修改
        fieldUrl.set(url, "192.168.10.155");
        System.out.println("数据库连接地址:" + fieldUrl);
        System.out.println("数据库连接地址:" + url);

 

相关文章:

  • 2022-01-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-21
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-01-03
  • 2022-02-27
  • 2022-12-23
  • 2022-12-23
  • 2021-12-18
  • 2021-10-23
相关资源
相似解决方案