Preface
forward engineering company previously used (forward engineering: generate Java code ----> database tables) write the structure of table fields and tables in the Java code to map to the database and generates the table structure, but in the use the process found some deficiencies.
So I was thinking, you can build the first database, and then generate code? With this question, so I take advantage of this period to study the epidemic mybatis reverse engineering (reverse engineering: Database ----> Java code that can be for a single table automatic generation of entity classes and other codes (mapper.java, mapper.xml, pojo ...) can make them siege lion will focus more on complex business logic) Next, we go to learn this mybatis reverse engineering use (single table)
1. to achieve the required installation of reverse engineering in the idea plug-in?
- 1.1 first need to install mybatis
Setting-Plugins- search "Mybatis Plugin" - Click Install
- 1.2 Installation easyCode
Setting-Plugins- search "easyCode" - Click Install
- 1.3 Restart idea
How 2.idea connect to the database?
Select the database corresponding to the type you want to connect, I used here is the mysql database
- 2.1 database input address, port number, user name, password, database name
- 2.2 Configuration driving connection
- 2.3 Click Test Connection, click Apply after successful
How to generate code 3. Connect?
- 3.1 selection table, and select Generate Code
- Select Code Type 3.2 generation
- 3.3 generate success
This is the idea provided in the mybatis and easyCode plug-ins, after the development will not have to spend time re-writing the code of a single table. I am not feeling a lot easier, hey!
I will continue to learn more behind the technology, and share with everyone!
Smart for hard work, genius is the accumulation. - Hua