您的位置:首页 > 其它

安装Hibernate jboss tools 去自动生成Hibernate 实体类及注解

2015-09-25 13:51 447 查看
1. 安装 Hibernate /jboss tools.
hibernate tool 安装下载地址: http://www.jboss.org/tools/download 



按照提示,拖动图标到eclipse 中去,就会自动安装了,注意eclipse 的版本。其实本质上也是通过eclipse market 安装的。

2. 重启eclipse,
安装完成之后,要求重启eclipse,

3. 检查Hibernate tool 是否正确安装.
打开试图,查看有没有hibernate:



4. 进入hibernate  Perspective, 并配置





选择 mysql 数据库,继续下一步.



我这里mysql 选择的是:mysql-connector-java-5.1.33-bin.jar

选择 “Configuration File“, 我这里在工程目录下新建了一个,软后选择新建的这个文件:


 程序代码

<?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">

<hibernate-configuration>

    <session-factory>

        <property name="hibernate.bytecode.use_reflection_optimizer">false</property>

        <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>

        <property name="hibernate.connection.username">root</property>

        <property name="hibernate.connection.password">123456</property>

        <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/cloudid</property>

        <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>

        <property name="show_sql">true</property>        

    </session-factory>

</hibernate-configuration>

5. 查看连接的数据库表



6. 利用hibernate tool 生成代码







点击 run 之后,生产的代码就到了指定的 export 的地方了.

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: