我想在下面添加配置文件/home/nameuser/.myProject/conf
在运行时将配置文件添加到类路径中。
我尝试使用URLClassLoader
但没有成功。
URL[] url={new URL("file://foo")};
URLClassLoader loader = new URLClassLoader(url);
或者
ClassLoader currentThreadClassLoader
= Thread.currentThread().getContextClassLoader();
// Add the conf dir to the classpath
// Chain the current thread classloader
URLClassLoader urlClassLoader
= new URLClassLoader(new URL[]{new File("mtFile").toURL()},
currentThreadClassLoader);
// Replace the thread classloader - assumes
// you have permissions to do so
Thread.currentThread().setContextClassLoader(urlClassLoader);