MiraiForum

    • 注册
    • 登录
    • 搜索
    • 热门
    • 最新
    • 未解决
    • 标签
    • 群组
    • 友情链接

    切换类加载器,解决Java Services 加载问题(大概也能解决Spring的上下文问题)

    技术交流板块
    1
    1
    414
    正在加载更多帖子
    • 从旧到新
    • 从新到旧
    • 最多赞同
    回复
    • 在新帖中回复
    登录后回复
    此主题已被删除。只有拥有主题管理权限的用户可以查看。
    • cssxsh
      cssxsh 最后由 编辑

          val thread = Thread.currentThread()
          val oc = thread.contextClassLoader
          try {
              thread.contextClassLoader = XXXPlugin::class.java.classLoader
              // 需要切换上下文的代码
          } finally {
              thread.contextClassLoader = oc
          }
      
      1 条回复 最后回复 回复 引用 4
      • Referenced by  cssxsh cssxsh 
      • Referenced by  Y Yuanning 
      • 1 / 1
      • First post
        Last post
      Powered by Mamoe Technologies & NodeBB | 友情链接 | 服务监控 | Contact