近段时在在学习用eclipse3.1.1+myeclipse4.1开发struts+hibernate,原来都是手写代码,第一次用,感觉很好,感觉到
原来写程序可以这么方便,同时也感觉到这方面的资料网上还算比较少了,至少网上介绍eclipse3.1.1+myeclipse4.1
组合开发的比较少
第一次用,遇到的问题也不少,虽说是依葫芦画瓢,但对eclipse3.1.1+myeclipse4.1不熟,导致对里面的struts,hibernate
集成开发不熟,第一个程序都搞了一天,现总结一下:
第一.struts依葫芦画瓢,不会出问题,最头痛的是hibernate,hibernate是myeclipse自带的持久层开发都是自动化的,他
自已自动合成一些东西,比如hibernate.cfg.xml自动合成,开始,我调不出程序是,没有自动导入包至lib目录里,一定要把
hibernate2.jar包导入至lib包里,还有就是看lib包里,所需的jar是否都有了,没有的话手动加进去
第二.这个问题搞的我很头晕,就是
<hibernate-configuration>
<session-factory>
<!-- properties -->
<property name="connection.username">root</property>
<property name="connection.url">jdbc:mysql://localhost:3306/addressbook</property>
<property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>
<property name="connection.password"></property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<!-- mapping files -->
<!-- The following mapping element was auto-generated in -->
<!-- order for this file to conform to the Hibernate DTD -->
<mapping resource="Add valid path"/>
</session-factory>
</hibernate-configuration>
加粗的地方是hibernate.cfg.xml自动生成的,这里要改成相应的*.hbm.xml对应的路径,要不会出现如下错误:
%%%% Error Creating SessionFactory %%%%
net.sf.hibernate.MappingException: Resource: Add valid path not found
<mapping resource="com/sonic/Userlist.hbm.xml" />
改成这样就OK了,因为刚开始玩,遇到的也就是这些问题,经验是慢慢积累的,完!