---
title: "classpath 资源载入"
author: "steven_cheng"
date: "2009-09-22T11:07:13Z"
tags: ["EXT", "Spring"]
slug: "classpath"
draft: false
lastmod: "2009-09-22T11:07:13Z"
id: 474080
url: "https://steven-cheng.iteye.com/blog/474080"
---

问题：原来，把lib包加入到-Djava.ext.dirs参数中，无法加载classes下的配置文件。

原因：怀疑，ext使用的classloader和用户程序的classloader不是一个，所以无法加载用户的classpath下的资源

解决办法：修改shell，用for循环把jar文件加入到classpath中

 

问题：spring ClassPathXmlApplicationContext 写的main方法，用classpath:xxx 启动spring ApplicationContext，spring资源文件很多，打包在classpath下的jar文件里，有一部分在classes里，使用了通配符\*\*，jar文件中很多文件没有找到

解决办法：把classpath:xxx改为classpath\*:xxx