为了账号安全,请及时绑定邮箱和手机立即绑定

myeclipse怎么自动生成

myeclipse10没法安装hibernate tool也没法自动生成hbm.xml

正在回答

3 回答

我的myeclipse运行成功了,

1.首先连接数据库,在myeclipse的右上角没有模糊的按钮

http://img1.sycdn.imooc.com//59a40aca000125c504180176.jpg

2.选择myeclipse DataBase Explorer

http://img1.sycdn.imooc.com//59a40aef0001fa7504130293.jpg

3.在空白处点击右键点击new按钮

http://img1.sycdn.imooc.com//59a40b180001cc8b03600626.jpg

4.如下图,自己配置好。

http://img1.sycdn.imooc.com//59a40b5a000197d605230657.jpg

5.按下图,直接点击next。

http://img1.sycdn.imooc.com//59a40b8e00011fa606000679.jpg

6.按下图,再次点击next。

http://img1.sycdn.imooc.com//59a40bb30001ba4d05910667.jpg

7.点击finish。

http://img1.sycdn.imooc.com//59a40be00001a7b305860667.jpg

然后生成了Students.hbm.xml文件。

最后按下面修改一下自动生成的Students.hbm.xml,修改成如下的代码:

<hibernate-mapping>

    <class name="Students" table="students" catalog="hibernate">

        <composite-id>

            <key-property name="sid" type="java.lang.Integer">

                <column name="sid" />

            </key-property>

            <key-property name="sname" type="java.lang.String">

                <column name="sname" length="20" />

            </key-property>

            <key-property name="gender" type="java.lang.String">

                <column name="gender" length="2" />

            </key-property>

            <key-property name="birthday" type="java.sql.Timestamp">

                <column name="birthday" length="19" />

            </key-property>

            <key-property name="address" type="java.lang.String">

                <column name="address" length="100" />

            </key-property>

        </composite-id>

    </class>

</hibernate-mapping>

最后,一旦 自动生成了Students.hbm.xml,,,hibernate.cfg.xml会自动添加这行代码

<mapping resource="./Students.hbm.xml" />


0 回复 有任何疑惑可以回复我~
#1

WOshows 提问者

非常感谢!
2017-09-04 回复 有任何疑惑可以回复我~

下载好hibernate组件,然后点eclipse 里的help,----install newsoftware,---add   然后选择location 和name,next ,next , finish.就完成了

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

myeclipse怎么自动生成

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信