MiraiForum

    • Register
    • Login
    • Search
    • Popular
    • Recent
    • Unsolved
    • Tags
    • Groups
    • 友情链接

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

    技术交流板块
    1
    1
    235
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • cssxsh
      cssxsh last edited by

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