[go: up one dir, main page]
More Web Proxy on the site http://driver.im/

CN108416035B - Disconf-based unified management method for database mapping files - Google Patents

Disconf-based unified management method for database mapping files Download PDF

Info

Publication number
CN108416035B
CN108416035B CN201810201474.0A CN201810201474A CN108416035B CN 108416035 B CN108416035 B CN 108416035B CN 201810201474 A CN201810201474 A CN 201810201474A CN 108416035 B CN108416035 B CN 108416035B
Authority
CN
China
Prior art keywords
file
disconf
sql
program
name
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201810201474.0A
Other languages
Chinese (zh)
Other versions
CN108416035A (en
Inventor
何云华
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Sichuan Changhong Electric Co Ltd
Original Assignee
Sichuan Changhong Electric Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Sichuan Changhong Electric Co Ltd filed Critical Sichuan Changhong Electric Co Ltd
Priority to CN201810201474.0A priority Critical patent/CN108416035B/en
Publication of CN108416035A publication Critical patent/CN108416035A/en
Application granted granted Critical
Publication of CN108416035B publication Critical patent/CN108416035B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/21Design, administration or maintenance of databases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Stored Programmes (AREA)

Abstract

The invention discloses a disconf-based unified management method for database mapping files, wherein a distributed server reads Dao type information first, and automatically generates a corresponding add-delete modify-check SQL statement template according to a type name, a method name and method parameters; as long as the distributed program is successfully operated once, the local area contains the most complete configuration files, the SQL mapping files do not need to be downloaded to the local area, and the SQL mapping files are added into the queue of the disconf hosted files, so that the corresponding SQL files are read from the line each time the program is started. Since the existing disconf only supports properties file updating, the properties file can be automatically injected, and can be immediately effective without restarting a program, the SQL mapping file is required to be immediately effective, and a callback function is required to be added to automatically inject the Java bean without restarting the program.

Description

Disconf-based unified management method for database mapping files
Technical Field
The invention relates to the technical field of computer technology and configuration management, in particular to a disconf-based database mapping file unified management method, and particularly relates to realization of distributed configuration management service and a unified solution scheme taking zookeeper and mybatis database operation as basic technologies.
Background
The Disconf (distributed configuration management platform) is a complete set of zookeeper-based distributed configuration unified solution. Deployment is extremely simple: the same upper package can run under a plurality of environments (RD/QA/PRODUCTION) without changing the configuration. The configuration is stored in the cloud system, distributed management of configuration items and configuration files can be supported, a non-code-intrusion programming mode based on XML and a weak code-intrusion programming mode based on annotation are supported, and a micro-service architecture is supported. Currently, the method is mainly used for hosting the properties and xml configuration files in projects. In the JavaWeb project, mybatis persistent layer framework is needed for storing data into a database, the mybatis persistent layer framework supports common SQL query, storage process and high-level mapping, and an interface and Java POJO are mapped into records in the database through XML mapping files. However, one Dao class corresponds to one SQL mapping file, one table in the database is operated, and the table can be subjected to various operations of adding, deleting, modifying and checking, and is written in the project codes one by one, so that the Dao class is large in workload, easy to make mistakes and troublesome to modify, and is considered to be hosted on disconf. The key point is that the disconf platform automatically generates and stores an SQL mapping file template according to the method name of the Dao class and the data source of the project configuration file, and simultaneously realizes the functions of immediate effect without restarting once modified.
Disclosure of Invention
Aiming at the defects in the prior art, the invention aims to provide a database mapping file unified management method based on disconf, wherein a distributed server reads Dao type information firstly, and automatically generates a corresponding add-delete modify-check SQL statement template according to a type name, a method name and method parameters; therefore, the interface function cannot be correctly realized, and the interface function can be correctly realized by saving the interface function after slightly modifying the interface function on line and starting the program again by a developer. As long as the distributed program is successfully operated once, the local area contains the most complete configuration files, the SQL mapping files do not need to be downloaded to the local area, and the SQL mapping files are added into the queue of the disconf hosted files, so that the corresponding SQL files are read from the line each time the program is started. Since the existing disconf only supports properties file updating, the properties file can be automatically injected, and can be immediately effective without restarting a program, the SQL mapping file is required to be immediately effective, and a callback function is required to be added to automatically inject the Java bean without restarting the program.
The purpose of the invention is realized by the following technical scheme:
a unified management method for database mapping files based on disconf comprises the following steps:
step A: configuring a performance file for a local project, wherein the performance file is a core of the local project using the relevant settings of the performance; properties file sets host, version, APP, environment of server, whether local uses remote configuration file, retry times of obtaining configuration and related content of dormancy time;
and B: adding basic disconf support in an entry configuration file of a local item, and injecting Java beans needing configuration; simultaneously adding a path and a file name of the SQL mapping file to be hosted and the XML file to be hosted, and injecting a Dao class;
and C: adding annotations to the Dao class, firstly marking the Dao class as a Spring hosted class, and specifying an SQL mapping file name which is consistent with a hosted file name in the entry XML; adding annotations to each method in the Dao class to ensure that the name of the method is consistent with the id of each statement in the SQL mapping file;
step D: when a local project program is started for the first time, the distributed server reads Dao type information firstly, and automatically generates a corresponding add-delete modify-check SQL statement template according to the type name, the method name and the method parameter; if the interface function cannot be correctly realized, a developer needs to slightly modify the interface on line and then store the modified interface, and then restart the program, so that the interface function can be correctly realized; once the SQL mapping file is generated, it will be automatically saved on the disconf-web for hosting;
step E: as long as the distributed program is successfully operated once, the local area contains the most complete configuration file, the SQL mapping file does not need to be downloaded to the local area, and the SQL mapping file is added into a queue of disconf hosted files, so that the corresponding SQL file is read from the line when the program is started each time; since the existing disconf only supports properties file updating, the properties file can be automatically injected, and can be immediately effective without restarting a program, the SQL mapping file is required to be immediately effective, and a callback function is required to be added to automatically inject the Java bean without restarting the program.
Preferably, step E further comprises the following steps:
the SQL mapping file corresponding to each Dao class in the local project is hosted on disconf, and then, each time a program is started, the database adding and deleting modification sentences of the SQL mapping file can be automatically read from the online, so that the database is operated.
Preferably, the method name in the Dao class in said step C must comply with the Java coding specification.
The present invention is based on the unified management of configuration files by disconf, provided that configuration files specifying database connections in an item have been hosted on a distributed configuration management platform.
Currently, the use of MySQL databases is quite widespread in java web projects. And performing a series of operations on the database through the SQL mapping file of mybatis. A Dao class is usually mainly oriented to a table in a database, and a corresponding SQL mapping file is needed to match attributes in a common Java object with fields in a database table. If the SQL statement is modified, the project needs to be recompiled, started, packaged and deployed, which is troublesome. Although the SQL mapping file is not a configuration file of a project, but is also a file of an XML type, while various configuration files of the types of Properties and XML are supported by disconf. In addition, different operations of adding, deleting, modifying and checking a plurality of tables are usually required in a project, currently, an SQL mapping file of each table needs to be completely created one by one, each SQL statement is written to perform CRUD on a database, and if a hump type naming automatic mapping statement is not performed in a mybatis configuration file, mutual mapping of class fields and table attributes needs to be added in the SQL file to ensure one-to-one correspondence and correct adding, deleting, modifying and checking. Some table fields are relatively more, the code writing amount in the development process is larger, and errors are easy to occur. In the invention, the corresponding SQL mapping file template is automatically generated by using the disconf platform, and a developer only needs to make appropriate modification and supplement.
At present, disconf implements two distributed management modes: (1) properties files do not need to define Java beans in project entry XML files, can be automatically injected during configuration updating, and does not need to restart programs; (2) the method is based on an XML code-free intrusion mode, supports configuration files of any type, needs to define Java beans in an XML file of a project entry, cannot automatically inject the Java beans during configuration updating, and needs to be supported by a party writing back a call function. In the invention, disconf is required to combine two configuration modes of annotation and XML according to specified conditions, firstly, an XML document template is automatically generated in a distributed server dosconf-web, and then, the XML document template is uniformly managed. The key steps include:
(1) adding basic disconf support in an entry configuration file (namely application context. xml under the spring programming environment) of a project, and defining a Java bean; adding a path and a file name of the SQL mapping file to be managed (the path and the file name must be in a format of field + mapper. xml of DAO removed by the Dao class name according to Java programming specification, otherwise, the managed file does not exist);
(2) adding annotation on the Dao class, firstly marking the Dao class as a Spring hosted class, and specifying a SQL mapping file name (which is consistent with a hosted file name in the entry XML); annotations are added to each method in the Dao class so that the method name is consistent with the id of each statement in the SQL mapping file. The method names in the Dao class must comply with the Java coding specification, namely: SELECT is prefixed by get, UPDATE is prefixed by UPDATE, INSERT is prefixed by save, DELETE is prefixed by remove.
(3) When the program is started for the first time, the distributed server reads the Dao type information first, and automatically generates a corresponding add-delete modify-check SQL statement template according to the type name, the method name and the method parameter. Therefore, the interface function cannot be correctly realized, and the interface function can be correctly realized by saving the interface function after slightly modifying the interface function on line and starting the program again by a developer. Unlike the properties configuration file, as long as the distributed program is successfully run once, the local will contain the most complete configuration file, the SQL mapping file does not need to be downloaded to the local, and since the SQL mapping file is already added to the queue of the disconf hosted files, the corresponding SQL file is read from the line each time the program is started. Since the existing disconf only supports properties file updating, the properties file can be automatically injected, and can be immediately effective without restarting a program, the SQL mapping file is required to be immediately effective, and a callback function is required to be added to automatically inject the Java bean without restarting the program.
Compared with the prior art, the invention has the following advantages and beneficial effects:
the method can contain the most complete configuration file locally as long as the distributed program is successfully operated once, the SQL mapping file does not need to be downloaded to the local, and the SQL mapping file is added into a queue of disconf hosted files, so that the corresponding SQL file can be read from the line when the program is started every time. Since the existing disconf only supports properties file updating, the properties file can be automatically injected, and can be immediately effective without restarting a program, the SQL mapping file is required to be immediately effective, and a callback function is required to be added to automatically inject the Java bean without restarting the program.
Drawings
FIG. 1 is a schematic flow chart of hosting an SQL mapping file to disconf in the present invention;
fig. 2 is a diagram of an approximate page display effect after the sql mapping file is stored in the distributed unified management platform according to the present invention.
Detailed Description
The present invention will be described in further detail with reference to the following examples:
example one
As shown in fig. 1, a unified management method for database mapping files based on disconf includes the following steps:
step A: configuring a performance file for a local project, wherein the performance file is a core of the local project using the relevant settings of the performance; properties file sets host, version, APP, environment of server, whether local uses remote configuration file, retry times of obtaining configuration and related content of dormancy time;
and B: adding basic disconf support in an entry configuration file of a local item, and injecting Java beans needing configuration; simultaneously adding a path and a file name of the SQL mapping file to be hosted and the XML file to be hosted, and injecting a Dao class;
and C: adding annotations to the Dao class, firstly marking the Dao class as a Spring hosted class, and specifying an SQL mapping file name which is consistent with a hosted file name in the entry XML; adding annotations to each method in the Dao class to ensure that the name of the method is consistent with the id of each statement in the SQL mapping file;
step D: when a local project program is started for the first time, the distributed server reads Dao type information firstly, and automatically generates a corresponding add-delete modify-check SQL statement template according to the type name, the method name and the method parameter; if the interface function cannot be correctly realized, a developer needs to slightly modify the interface on line and then store the modified interface, and then restart the program, so that the interface function can be correctly realized; once the SQL mapping file is generated, it will be automatically saved on the disconf-web for hosting;
step E: as long as the distributed program is successfully operated once, the local area contains the most complete configuration file, the SQL mapping file does not need to be downloaded to the local area, and the SQL mapping file is added into a queue of disconf hosted files, so that the corresponding SQL file is read from the line when the program is started each time; since the existing disconf only supports properties file updating, the properties file can be automatically injected, and can be immediately effective without restarting a program, the SQL mapping file is required to be immediately effective, and a callback function is required to be added to automatically inject the Java bean without restarting the program.
Wherein the step E also comprises the following steps:
the SQL mapping file corresponding to each Dao class in the local project is hosted on disconf, and then, each time a program is started, the database adding and deleting modification sentences of the SQL mapping file can be automatically read from the online, so that the database is operated.
The method name in the Dao class in said step C must comply with the Java coding specification.
Example two
As shown in fig. 1 and fig. 2, a unified management method for a database mapping file based on disconf includes the following steps:
the method comprises the following steps: properties files are created locally to the project. Since it is a distributed server-initiated portal. The file is configured with the host, version, APP, environment of the server, and whether to use the remote configuration file locally, retry times and sleep time of the acquisition configuration, and other related contents.
Step two: the XML file is an application context XML file in the project entry XML file under the Spring programming environment. Adding basic disconf support, scanning a package of a local item of the user, adding an XML file to be managed, wherein the XML file is an SQL mapping file corresponding to each Dao class, the file name accurately corresponds to the Dao class name, and adding a Java bean to be configured, namely Spring injection into the Dao class.
Step three: annotations are added to the Dao class that interact with the database. Firstly, marking the SQL sentence template as a Spring hosted class, and secondly, appointing a corresponding SQL mapping file name by the annotation on the class name so as to accurately find the SQL sentence to be executed when the program is started, wherein the annotation on each method appoints the unique id of each SQL sentence in the SQL mapping file, thereby being convenient for generating the correct SQL sentence template.
Step four: the distributed server generates an SQL mapping file template corresponding to Dao class. When a program is started for the first time, a file to be hosted in a project XML file does not exist on the disconf-web, so that each corresponding Dao class is associated according to the file name of the file, an SQL mapping file is created according to each method name and method parameter in the Dao classes, a preliminary SQL statement is generated, and the preliminary SQL statement is stored on a distributed server. Then, the developer needs to further modify the SQL statement in a supplementary way and save the update.
Step five: disconf-web distributed servers host uploaded XML files. This has the advantage that the same online package can be deployed in different environments, unlike the previous need to copy one copy on each server. For files of properties type, on-line modification, the program can automatically reload configuration, and the boot program is deployed locally without repackaging. For the xml type file, the online update is performed, the program cannot be automatically loaded to be newly modified, and the callback function needs to be manually added to acquire the latest configuration file.
Step six: and starting the program again, reading the content from the SQL mapping file on the disconf-web, and operating the database. All types of configuration files that are declared hosted in the project XML file may exist locally or remotely. And as long as the distributed program is successfully operated once, even if the distributed program is not operated before the local, the distributed program can be downloaded to the local, if the remote configuration file is failed to be acquired during subsequent starting, the program automatically reads the local file, and the normal operation of successful attack in the wrong direction cannot be influenced.
As shown in fig. 2, after the sql mapping file is saved in the distributed unified management platform, the sql mapping file can be edited in different environments, and the approximate page display effect is shown in this figure.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents and improvements made within the spirit and principle of the present invention are intended to be included within the scope of the present invention.

Claims (3)

1. A unified management method for database mapping files based on disconf is characterized in that: the method comprises the following steps:
step A: configuring a performance file for a local project, wherein the performance file is a core of the local project using the performance; properties file sets host, version, APP, environment of server, whether local uses remote configuration file, retry times of obtaining configuration and dormancy time;
and B: adding disconf support in an entry configuration file of a local project, and injecting Java beans needing configuration; simultaneously adding a path and a file name of the SQL mapping file to be hosted and the XML file to be hosted, and injecting a Dao class;
and C: adding annotations to the Dao class, firstly marking the Dao class as a Spring hosted class, and specifying an SQL mapping file name which is consistent with a hosted file name in the entry XML; adding annotations to each method in the Dao class to ensure that the name of the method is consistent with the id of each statement in the SQL mapping file;
step D: when a local project program is started for the first time, the distributed server reads Dao type information firstly, and automatically generates a corresponding add-delete modify-check SQL statement template according to the type name, the method name and the method parameter; if the interface function cannot be correctly realized, the interface function can be correctly realized by saving the modified interface function after the modified interface function is modified on line by a developer and restarting a local project program; once the SQL mapping file is generated, it will be automatically saved on the disconf-web for hosting;
step E: as long as the distributed program is successfully operated once, the local system can contain the most complete configuration file, the SQL mapping file does not need to be downloaded to the local system, and the SQL mapping file is added into a queue of disconf hosted files, so that the corresponding SQL file can be read from the line each time the distributed program is started; since the existing disconf only supports properties file updating, the properties file can be automatically injected, and can be immediately effective without restarting the distributed program, the SQL mapping file is required to be immediately effective, and a callback function is required to be added to automatically inject the Java bean without restarting the distributed program.
2. A disconf-based database map file unified management method according to claim 1, characterized in that: wherein the step E also comprises the following steps:
the SQL mapping file corresponding to each Dao class in the local project is hosted on disconf, and then, each time the distributed program is started, the database adding, deleting, modifying and checking statements of the SQL mapping file can be automatically read from the online, so that the database is operated.
3. A disconf-based database map file unified management method according to claim 1, characterized in that: the method name in the Dao class in said step C must comply with the Java coding specification.
CN201810201474.0A 2018-03-12 2018-03-12 Disconf-based unified management method for database mapping files Active CN108416035B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810201474.0A CN108416035B (en) 2018-03-12 2018-03-12 Disconf-based unified management method for database mapping files

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810201474.0A CN108416035B (en) 2018-03-12 2018-03-12 Disconf-based unified management method for database mapping files

Publications (2)

Publication Number Publication Date
CN108416035A CN108416035A (en) 2018-08-17
CN108416035B true CN108416035B (en) 2021-06-22

Family

ID=63131107

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810201474.0A Active CN108416035B (en) 2018-03-12 2018-03-12 Disconf-based unified management method for database mapping files

Country Status (1)

Country Link
CN (1) CN108416035B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109491649A (en) * 2018-11-20 2019-03-19 北京千丁互联科技有限公司 Dao code generating method and terminal
CN110046170B (en) * 2019-04-22 2021-07-27 深圳乐信软件技术有限公司 Statement execution method, device, equipment and medium based on multi-file management
CN112199334B (en) * 2020-10-23 2023-12-05 东北大学 Method and device for processing check point file storage by data flow based on message queue

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106685706A (en) * 2016-12-14 2017-05-17 深圳中顺易金融服务有限公司 Zookeeper based configuration update method and system
CN106815012A (en) * 2016-12-14 2017-06-09 深圳中顺易金融服务有限公司 Decentralized configuration Explore of Unified Management Ideas and system based on Zookeeper

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6807490B1 (en) * 2000-02-15 2004-10-19 Mark W. Perlin Method for DNA mixture analysis

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106685706A (en) * 2016-12-14 2017-05-17 深圳中顺易金融服务有限公司 Zookeeper based configuration update method and system
CN106815012A (en) * 2016-12-14 2017-06-09 深圳中顺易金融服务有限公司 Decentralized configuration Explore of Unified Management Ideas and system based on Zookeeper

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
Disconf irmation of Expectations of Utility in e-Learning;ROSARIO CACAO;《International journal on E-learning》;20131231;第3卷(第12期);229-247 *

Also Published As

Publication number Publication date
CN108416035A (en) 2018-08-17

Similar Documents

Publication Publication Date Title
US9465590B2 (en) Code generation framework for application program interface for model
US6816868B1 (en) Database system
US8381176B1 (en) Software build orchestration framework
CN108762743B (en) Data table operation code generation method and device
US20070245332A1 (en) Method and apparatus to perform an application software migration
CN108416035B (en) Disconf-based unified management method for database mapping files
US20080098037A1 (en) Markup language based database upgrades
CN103995854A (en) Equipment cross-version upgrading method and device
CN110457385B (en) Materialized database objects in a multi-tenant environment
GB2459572A (en) Producing configuration file wrappers for resources based on metadata
CN107679056B (en) Method for generating SQL (structured query language) statement, electronic device and readable storage medium
US20140258321A1 (en) Dynamic bridging of application and data servers
CN109976803B (en) File generation method and device
CN110489401B (en) Method and device for deploying database objects
CN111273942A (en) Code generation method, storage medium, electronic device and system
CN113064593A (en) Method and device for dynamic mobile APP, computer equipment and storage medium
CN117312270A (en) Change management method for automatic construction and deployment of database
US11936741B2 (en) Workspace databases
CN108471433B (en) Configurated synchronous message verification receiving method, system and storage medium
US9244706B2 (en) Command line shell command generation based on schema
CN112748905B (en) Method and device for initializing and calling basic library, electronic equipment and storage medium
CN114115952A (en) Method and device for automatically upgrading packaged low-code application
CN106547763B (en) Database creation method and device
CN114860224B (en) Implementation method of Web terminal map programmable layer
CN108932121B (en) Multi-tenant distributed service component research and development oriented module and method

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant