Can I create a custom classpath on a per application basis in Tomcat

前端 未结 4 1360
粉色の甜心
粉色の甜心 2020-11-30 00:16

For some applications I use ZK, others Hibernate, other Apache Commons, etc.

I don\'t want to deploy a 75MB war file, just because it uses lots of libraries.

4条回答
  •  粉色の甜心
    2020-11-30 00:23

    Another a bit hacky alternative.

    You can write a 5-6 line custom class loader which derives from urlclassloader, and simply adds your classpath jars using addUrl() method.

    Then set it as the context class loader of the thread in your application code.

    Thread.setContextClassLoader(new CustomClassloader(path, parentClassLoader)
    

    where parent class loader typically is

    Thread.getContextClassloader()
    

提交回复
热议问题