idea连接数据库并创建实体

IDEA版本:2018

1.连接数据库

找到Database选项,第一种,在左下角点击正方形图案,第二种在工具栏选择,均如图

2.找到MySQL,上一步之后右边会出现数据库窗口,如图

3.连接数据库

4.添加数据库连接的jar包,点击蓝色的MySQL

5.建立表映射

5.1配置hibernate.cfg.xml

File→Project Structure→Modules→+→Hibernate→+hibernate.cfg.xml

6.持久化

6.1配置persistence.xml

File→Project Structure→Modules→+→JPA→+→persistence.xml

注:

1.关于这些选择框的作用见https://blog.csdn.net/qq_32938169/article/details/82389690

2.如果出现please choose persistence unit的问题,配置hibernate.cfg.xml建立映射,再配置persistence.xml建立持久化

结果:

猜你喜欢

转载自blog.csdn.net/qq_31580493/article/details/87896957