详细解决方案
Exception in thread "main" org.hibernate.HibernateException: /hibernate.cfg.xml解决办法
热度:5786 发布时间:2013-02-25 21:04:58
public static void main(String args[]){
Configuration config=new Configuration().configure(); //读取默认的hibernate.cfg.xml的文件
SessionFactory sessionFactory=config.buildSessionFactory(); //通过config创建sessionFactory的实例
Session session=sessionFactory.openSession(); //获得session
}
在 WEB-INT中有 hibernate.cfg.xml。
这段代码报错,请问如何处理?谢谢。
Exception in thread "main" org.hibernate.HibernateException: /hibernate.cfg.xml not found
at org.hibernate.util.ConfigHelper.getResourceAsStream(ConfigHelper.java:147)
at org.hibernate.cfg.Configuration.getConfigurationInputStream(Configuration.java:1405)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1427)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1414)
at com.corona.web.action.SaveTrouble1Action.main(SaveTrouble1Action.java:355)
这不是提示你文件没找到吗,路径问题,你这个文件放在src根目录下了吗?目录结构和代码贴上来。都展开。改为Configuration config=new Configuration().configure("/WEB-INF/hibernate.cfg.xml");
默认是加载src下的。你说没有src目录,那你测试类放在什么地方?在根目录建个config文件夹,放到config里面吧,WEB-INF下的文件,不能直接访问。
相关解决方案
- hibernate 存入数据库当前时间
- Hibernate 投射文件中length属性无法改变integer字段的默认长度
- struts2 对象属性流入不进去, 报错:target is null for setProperty(null, "x" [Ljava.lang.Stri
- request.setAttribute("list" "''");该怎么解决
- Exception in thread "main" org.hibernate.HibernateException: /hibernate.cfg.xml解决办法
- struts2标签 <s:if test="表达式">表达式的写法解决方案
- xml文件不能被准确解析/The processing instruction target matching "[xX][mM][lL]" is not al
- sql中获取d天后的日期,格式为"yyyyMMdd"怎么做到
- hibernate DAO中加了局物,未提交
- hibernate 字段lazy 的兑现原理
- Hibernate 的query.list()的有关问题
- Hibernate 关联表字段赋值有关问题
- 零配置的有关问题(struts2+Hibernate)
- spring @Scope("prototype")注解更新有关问题,寻求帮助
- 怎么在eclipse的JSP裡在使用JS語法時可以直接""後出現方法
- 关于request.getParamater("name")若干疑点,html5新特性placeholder
- hibernate 连接 oracle session 有关问题
- java.lang.NumberFormatException: For input string: "id"该如何处理
- hibernate 中没有做一对多 , 那种关联映射的关联的话如何做连接查询
- jquery,二维数组取值。解决办法
- 怎么取<s:property value="news.CONTENT" escape="false"/>内容前几位
- 为什么Ext.getCmp("panelID").collapsed = false;无效呢
- 求架构方案:一个日均访问量50万的物流筛单系统的技术架构方案?解决办法
- hibernate 联接mysql出错
- 大神们开始觅错啦!org.hibernate.exception.SQLGrammarException: could not execute query
- 新人第一帖!JSF有关问题:<h:inputText value="{user.name}"/>
- request.setAttribute("message" message)不能传int参数,该怎么处理
- 关于 if(rs.getString("").trim().equals(""))解决办法
- struts2,hibernate,spring3 常用框架的API CHM版本,该怎么处理
- <base href="<%=basePath%>"> 有关问题