求帮忙 真心找不到哪漏什么了目录结构
src
-User.java
-User.hbm.xml
-ExportDB.java
hibernate.cfg.xmlUser.java
package xyh;import java.util.Date;public class User { private String id;
private String name;
private String password;
private Date createTime;
private Date expireTime; public String getId() {
return id;
} public void setId(String id) {
this.id = id;
} public String getName() {
return name;
} public void setName(String name) {
this.name = name;
} public String getPassword() {
return password;
} public void setPassword(String password) {
this.password = password;
} public Date getCreateTime() {
return createTime;
} public void setCreateTime(Date createTime) {
this.createTime = createTime;
} public Date getExpireTime() {
return expireTime;
} public void setExpireTime(Date expireTime) {
this.expireTime = expireTime;
}
}User.hbm.xml<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="xyh.User" table="t_user" >
<id name="id">
<generator class="uuid"/>
</id>
<property name="name"/>
<property name="password"/>
<property name="createTime"/>
<property name="expireTime"/>
</class>
</hibernate-mapping>
hibernate.cfg.xml<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"><!-- Generated by MyEclipse Hibernate Tools. -->
<hibernate-configuration> <session-factory>
<property name="dialect">org.hibernate.dialect.SQLServerDialect</property>
<property name="connection.url">jdbc:sqlserver://127.0.0.1:1433;databaseName=TESTHIB</property>
<property name="connection.username">sa</property>
<property name="connection.password">123456</property>
<property name="connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
<property name="myeclipse.connection.profile">sql</property>
<property name="show_sql">true</property>
<mapping resource="xyh.User.hbm.xml" />
</session-factory></hibernate-configuration>运行这个出错package xyh;import org.hibernate.cfg.Configuration;
import org.hibernate.tool.hbm2ddl.SchemaExport;/**
* 将hbm生成ddl
* @author Administrator
*
*/
public class ExportDB { public static void main(String[] args) {
//默认读取hibernate.cfg.xml文件
Configuration cfg = new Configuration().configure();
SchemaExport export = new SchemaExport(cfg);
export.create(true, true);
}
}Exception in thread "main" org.hibernate.MappingNotFoundException: resource: xyh.User.hbm.xml not found
at org.hibernate.cfg.Configuration.addResource(Configuration.java:563)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1587)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1555)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1534)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1508)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1428)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1414)
at xyh.ExportDB.main(ExportDB.java:16)
src
-User.java
-User.hbm.xml
-ExportDB.java
hibernate.cfg.xmlUser.java
package xyh;import java.util.Date;public class User { private String id;
private String name;
private String password;
private Date createTime;
private Date expireTime; public String getId() {
return id;
} public void setId(String id) {
this.id = id;
} public String getName() {
return name;
} public void setName(String name) {
this.name = name;
} public String getPassword() {
return password;
} public void setPassword(String password) {
this.password = password;
} public Date getCreateTime() {
return createTime;
} public void setCreateTime(Date createTime) {
this.createTime = createTime;
} public Date getExpireTime() {
return expireTime;
} public void setExpireTime(Date expireTime) {
this.expireTime = expireTime;
}
}User.hbm.xml<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="xyh.User" table="t_user" >
<id name="id">
<generator class="uuid"/>
</id>
<property name="name"/>
<property name="password"/>
<property name="createTime"/>
<property name="expireTime"/>
</class>
</hibernate-mapping>
hibernate.cfg.xml<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"><!-- Generated by MyEclipse Hibernate Tools. -->
<hibernate-configuration> <session-factory>
<property name="dialect">org.hibernate.dialect.SQLServerDialect</property>
<property name="connection.url">jdbc:sqlserver://127.0.0.1:1433;databaseName=TESTHIB</property>
<property name="connection.username">sa</property>
<property name="connection.password">123456</property>
<property name="connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
<property name="myeclipse.connection.profile">sql</property>
<property name="show_sql">true</property>
<mapping resource="xyh.User.hbm.xml" />
</session-factory></hibernate-configuration>运行这个出错package xyh;import org.hibernate.cfg.Configuration;
import org.hibernate.tool.hbm2ddl.SchemaExport;/**
* 将hbm生成ddl
* @author Administrator
*
*/
public class ExportDB { public static void main(String[] args) {
//默认读取hibernate.cfg.xml文件
Configuration cfg = new Configuration().configure();
SchemaExport export = new SchemaExport(cfg);
export.create(true, true);
}
}Exception in thread "main" org.hibernate.MappingNotFoundException: resource: xyh.User.hbm.xml not found
at org.hibernate.cfg.Configuration.addResource(Configuration.java:563)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1587)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1555)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1534)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1508)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1428)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1414)
at xyh.ExportDB.main(ExportDB.java:16)
解决方案 »
- js验证错了 页面还是提交了????99999我 十万火急
- 如何获取同一个浏览器的cookie值
- 页面删掉后,但还是跳到旧页面上去,重启weblogic,重新部署都不行
- http://www.265.com/ 首页上面的眼睛会随着鼠标转,是怎么做的?
- JSF中 绑定了数据源的下拉列表怎么设置默认值
- showModalDialog()在不关闭的情况下,让父窗口得到值
- web项目
- 连接SQL 2000表格问题!!在线等!
- 一个简单的问题:在JSP中如何自动返回上一级网页?
- 急!!携程机票查询的web service接口在java中如何实现?
- 连sql2008数据库出错了,请帮忙看看哪里的问题?
- 大侠们求助ajax在火狐下不能运行
src
xyh
-User.java
-User.hbm.xml
-ExportDB.java
hibernate.cfg.xml
<mapping resource="xyh/User.hbm.xml" />