日期:2014-05-18  浏览次数:20682 次

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就行了