读书人

Spring找不到applicationContext.xml文

发布时间: 2012-02-01 16:58:19 作者: rapoo

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

读书人网 >Java Web开发

热点推荐