第一次用hibernate,按书上写的配置好了,但是运行test的时候,总是说
Exception in thread "main" java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.<init>(I)V
怎么会没有main呢?test.javapackage hibernate;
import org.hibernate.*;
import org.hibernate.cfg.*;
public class test { public static void main(String[] args) {
try {
SessionFactory sf = new Configuration().configure().buildSessionFactory();
Session session = sf.openSession();
Transaction tx = session.beginTransaction(); for (int i = 0; i < 200; i++) {
user User = new user();
User.setUserName("customer" + i);
User.setPassWord("customer");
session.save(User);
} tx.commit();
session.close();
} catch (HibernateException e) {
e.printStackTrace();
}
}
}user.hbm.xml的配置是<?xml version="1.0" encoding="GBK"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"><hibernate-mapping>
<class name="hibernate.user" table="user">
<id name="id" column="id"><generator class="identity"/></id>
<property name="userName" type="string">
<column name="userName" length="64" not-null="true"/>
</property>
<property name="passWord" type="string">
<column name="passWord" length="64" not-null="true"/>
</property>
<property name="email" type="string">
<column name="email" length="64" not-null="true"/>
</property>
</class>
</hibernate-mapping>
user类就不写了,就像一个bean那样
Exception in thread "main" java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.<init>(I)V
怎么会没有main呢?test.javapackage hibernate;
import org.hibernate.*;
import org.hibernate.cfg.*;
public class test { public static void main(String[] args) {
try {
SessionFactory sf = new Configuration().configure().buildSessionFactory();
Session session = sf.openSession();
Transaction tx = session.beginTransaction(); for (int i = 0; i < 200; i++) {
user User = new user();
User.setUserName("customer" + i);
User.setPassWord("customer");
session.save(User);
} tx.commit();
session.close();
} catch (HibernateException e) {
e.printStackTrace();
}
}
}user.hbm.xml的配置是<?xml version="1.0" encoding="GBK"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"><hibernate-mapping>
<class name="hibernate.user" table="user">
<id name="id" column="id"><generator class="identity"/></id>
<property name="userName" type="string">
<column name="userName" length="64" not-null="true"/>
</property>
<property name="passWord" type="string">
<column name="passWord" length="64" not-null="true"/>
</property>
<property name="email" type="string">
<column name="email" length="64" not-null="true"/>
</property>
</class>
</hibernate-mapping>
user类就不写了,就像一个bean那样
解决方案 »
- 各位有经验的选手,帮我研究个听纠结的问题?
- 急!!!如何获取WebService请求的soap包头 java
- 我的一对一主键关联通过主对象查关联对象的属性为什么会出现N+1
- Struts2 action 路径问题 (There is no Action mapped for action name loginAction)
- 请问 JSP 做的程序为什么开始运行是正常的 运行一会就不能运行了 需要重起TOMCAT
- J2EE开发webservice,客户端调用webservice的时候传值为空(NULL)问题
- hibernte不能执行查询问题
- 关于Hibernate 的一个SUM()输出问题
- 我公司的网络是代理服务器的形式,请问在这种情况下怎样发布数据库jsp程序?
- Hibernate多对多排序问题
- struts中标签的属性
- Hibernate中一对多关系的删除问题
type="string ==》type="java.lang.String"
另外顺便说一句,你把错误信息翻译错了。其实错误信息说的是:“在主线程中出现了没有这个方法异常”不要看见"main",就想着是main方法。恰恰人家说的是thread main:主线程。另外,楼主的语法规范太差了!类名首字母要大写,你怎么都小写了?变量名的首字母要小写,你怎么又都搞些大写?
重点关注asm-attrs.jar ,直接使用myeclipse做较好