1. Requirements Description:
After the software development is completed, the delivery customer usually needs the database design document before the customer uses, many programmers even the project manager naturally thought to adopt human sea tactics, a project group member, sub-module to write, then merges. As programmers, this approach is too low. So can there be automated tools, of course, with degrees Niang search "database document Generator" will come out many, their quality will be uneven, or format does not meet the company document format needs. So the ultimate solution to this problem is to understand the principle of database document generator, and then do it yourself, it sounds difficult, it is not easy to achieve, no picture no truth, first.
2. Technical Point Analysis:
The above generated is not very cool, now we are in step by step analysis is how to generate.
The tools you need |
Role |
Microsot Office |
Used to generate a Word document template |
Development language |
Java |
Freemarker |
Java Template language |
Jdbc |
Using JDBC to get the definition of a table |
This problem can be split into:
- Word document Template: Ordinary doc, docx are binary files, the operation is more troublesome, then we can use the alternative way, in Word XML format.
Save a look at what the doc in XML format looks like:
Heavenly Book of the same XML, is not very broken, in fact, you do not need to fully understand, understand the structure, find out what you care about, if you can not go back and forth more than a few times.
- Table structure meta-data:
The classmate who writes Java, should know this is what, perhaps you have not used, but he is existence.
- Combine templates and metadata to generate the documents we need.
From the template XML, find the part that needs to be looped, plus the foreach tag:
OK, now that the data has, the template has, the problem is solved.
3. Code implementation:
1. Get a list of table structures:
2. Generate a doc file from a template
4. PostScript:
With the idea of template + data, you can produce documents of any format in complex format, such as generating "* * * * * * * * * * * * * * * * * * *", and can reduce the development difficulty, improve development speed.
Java Development, Internet architecture discussion QQ Group: 297702426
Email: [Email protected]
database table Structure Document auto-generation tool