首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

Spring找不到applicationContext.xml文件,该如何处理

2012-02-01 
Spring找不到applicationContext.xml文件 我使用的是开始使用spring框架,在使用数据源连接数据库时报找不

Spring找不到applicationContext.xml文件

我使用的是开始使用spring框架,在使用数据源连接数据库时报找不到applicationContext.xml文件.

我的工程名为ssh;
applicationContext.xml在web-inf下面
具体位置:
ssh
|-src
--|--com.conDAO
|-ssh
--|--web-inf
-------+web-inf  


以下是com.conDAO的部分

private   static   String   CONFIG_FILE_LOCATION   = "/ssh/ssh/web-inf/web-inf ";

/**   Holds   a   single   instance   of   Session   */
private   static   final   ThreadLocal   threadLocal   =   new   ThreadLocal();

/**   The   single   instance   of   hibernate   configuration   */
private   static   final   Configuration   cfg   =   new   Configuration();

/**   The   single   instance   of   hibernate   SessionFactory   */
private   static   org.hibernate.SessionFactory   sessionFactory;

public   static   Session   currentSession()   throws   HibernateException   {
Session   session   =   (Session)   threadLocal.get();
           
if   (session   ==   null   ||   !session.isOpen())   {
if   (sessionFactory   ==   null)   {
try   {
cfg.configure(CONFIG_FILE_LOCATION);//这儿有问题
sessionFactory   =   cfg.buildSessionFactory();
}   catch   (Exception   e)   {
System.err.println( "%%%%   Error   Creating   SessionFactory   %%%% ");
e.printStackTrace();
}
}
session   =   (sessionFactory   !=   null)   ?   sessionFactory.openSession()
:   null;
threadLocal.set(session);
}
return   session;
}

--------------
private   static   String   CONFIG_FILE_LOCATION   = "/ssh/ssh/web-inf/web-inf ";

cfg.configure(CONFIG_FILE_LOCATION);
这儿有问题!请教大家如何解决



[解决办法]
直接用/WEB-INF/applicationContext.xml就行了

热点排行