Renren open source code generator
This article mainly includes three parts: introduction, code generation demonstration, code analysis (not very in-depth), etc
The three parts are enough for you to learn to use. The problems that may be encountered in actual production will not be encountered here.
The function of code generator is to improve development efficiency. However, this code generator still has its limitations because it does not have multi table and cascade related code generation. Only for a single table. This is a big limitation.
1、 Introduction
The idea of Renren generator code generation is mainly through volocity template and in the form of zip package.
Its technology stack is mainly as follows:
What the technology stack contains can be said to be familiar to most of our Java programmers.
So for learning, the cost is not high. Someone who has experience in using the technology contained in the technology stack.
The project structure is as follows:
2、 Code generation demonstration process
Premise: there must be a Ren security item locally. You can import it locally through git clone or download and unzip it.
1. Run the startup class in Ren generator
2. After successful operation, enter the address in the browser: http://localhost:8082/renren -Generator, as shown below
3. Select the corresponding table, such as the table you created
4. Generate the corresponding zip package
5. Copy it to the corresponding folder and unzip it
6. After code generation, the process to be done is
(1) Put the Java code and the corresponding XML under the corresponding package according to the classification
(2) The front-end code is placed in the corresponding folder according to the classification
(3) Execute SQL script
Open goods_ menu. SQL file, copy the contents, open the local database client tool (sqlyog or Navicat), and select the corresponding database for execution.
(4) Run Ren admin (this Ren admin can be understood as our multi tenant project), log in to the system background, and you will find a commodity management problem
(5) To be on the safe side, test the corresponding add, modify and delete functions. If it is found that they can be executed normally without error messages, it means that the process is OK
3、 Generated code analysis
(1) SQL script
(2) Entity code
Consistent with mybatis plus, we happen to have experience in using mybatis plus, which can seamlessly transition without technical cost
(3) Dao code
Same as (1)
(4) Service code
Like (1), the difference is that a page is added
(5) Service implementation class code
Consistent with (3)
(6) Controller code
The generated controller has list display, addition, deletion, single query, modification, etc., and does not need to be written manually
(7) XML code
It is not much different from the original mybatis plus
(8) JS code
Vue is mainly used JS (version 2.0)
(9) HTML code
It mainly adopts volocity template engine and Vue js