Method and device for determining dependency relationship between class and library table, equipment, medium and product

By introducing JAR files and interceptors into the Spring framework to parse SQL statements, combined with recursive algorithms and a visual interface, the problem of difficult-to-discern implicit library table dependencies in enterprise-level Java application systems is solved, achieving efficient and accurate dependency analysis.

CN121349530APending Publication Date: 2026-01-16BANK OF COMMUNICATIONS
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511376997.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-09-25
Publication Date
2026-01-16

AI Technical Summary

Technical Problem

In existing technologies, the identification of implicit library table dependencies in enterprise-level Java application systems mainly relies on manual code review, which is inefficient and makes it difficult to complete a comprehensive analysis within the project cycle.

Method used

By introducing a JAR file into the Spring framework, interceptors are used to intercept SQL statements and method names. Combined with the Jsqlparser parser, the dependency classes of the controller layer beans are probed step by step to form a clear dependency chain between classes and database table information. A recursive algorithm and a visual query interface are used for analysis.

Benefits of technology

It improves analysis efficiency, reduces the probability of missed and incorrect migrations, enhances the accuracy and coverage of dependencies, saves human resources, and is low-cost and high-performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121349530A_ABST
    Figure CN121349530A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a category and library table dependency relationship determination method and device, equipment, a medium and a product. The method comprises the following steps: for any data access layer bean in a target project, running a first execution code corresponding to the data access layer bean; according to an SQL statement generated during the operation of the first execution code and a method name for calling the SQL statement, determining a first dependency relationship between a method contained in the data access layer bean and library table information; for any control layer bean in the target project, detecting dependency classes of all hierarchies corresponding to the control layer bean through a recursive algorithm, and when the dependency classes are data access layers bean, determining methods included in the data access layers bean; and determining the dependency relationship between the classes and the library table information in the target project according to the dependency classes of all hierarchies corresponding to each control layer bean, the methods contained in the data access layer bean and the first dependency relationship corresponding to each data access layer bean, so that the overall efficiency of analysis can be improved, and the probability of misplacement missing and misplacement can be reduced.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computer, and in particular, to a class and library table dependency relationship determination method, device, equipment, medium and product. BACKGROUND

[0002] Enterprise Java application systems, as an important carrier to support the core business of key industries such as finance, telecommunications and energy, usually have typical characteristics such as large scale, complex function, high module coupling degree, etc. Such systems often evolve for a long time and iterate for many times, accumulating millions of lines of code, even tens of millions of lines of code, containing a large number of business logic components, data access objects and control layer components.

[0003] The migration work not only involves the replacement or reconstruction of the underlying database, but also needs to be synchronized to complete the adaptation and modification of all Java code related to it. Due to historical reasons, the situation of missing or updating not in time of system documents is widespread, and there are a large number of implicit and non-explicitly declared dependency relationships between database table structures and business code logic.

[0004] At present, the enterprise mainly relies on the manual code review and experience judgment of the developer to sort out such implicit dependency relationships. This method has obvious limitations: the efficiency of manual sorting is extremely low, and it is difficult to complete comprehensive analysis within the project cycle by relying entirely on manual inspection in the face of massive code library. SUMMARY

[0005] The embodiments of the present application provide a class and library table dependency relationship determination method, device, equipment, medium and product, to improve the analysis efficiency and accuracy.

[0006] In a first aspect, the embodiments of the present application provide a class and library table dependency relationship determination method, which comprises:

[0007] For any data access layer bean in the target project, the first execution code corresponding to the data access layer bean is run; the first dependency relationship between the method contained in the data access layer bean and the library table information is determined according to the SQL statement generated during the running of the first execution code and the method name calling the SQL statement; wherein the library table information includes the identifier of the library table and the identifier of the database to which the library table belongs; the library table information is obtained by analyzing the SQL statement;

[0008] For any control layer bean in the target project, the dependent classes of all levels corresponding to the control layer bean are detected by a recursive algorithm, and when the dependent class is a data access layer bean, the method contained in the data access layer bean is determined.

[0009] According to the dependency classes of all levels corresponding to each control layer bean and the methods contained in the data access layer bean, the first dependency relationship corresponding to each data access layer bean, the dependency relationship between the classes and the library table information in the target project is determined.

[0010] Optionally, according to the SQL statement generated during the running of the first execution code and the method name for calling the SQL statement, the first dependency relationship between the methods contained in the data access layer bean and the library table information is determined, and the method comprises the following steps:

[0011] During the running of the first execution code, the generated SQL statement and the method name for calling the SQL statement are intercepted by using an interceptor;

[0012] The SQL statement is parsed by using a Jsqlparser parser to obtain the library table information corresponding to the SQL statement;

[0013] According to the method name for calling the SQL statement and the library table information corresponding to the SQL statement, the first dependency relationship between the methods contained in the data access layer bean and the library table information is determined.

[0014] Optionally, the method further comprises:

[0015] The xml source file information of the SQL statement is intercepted by using an interceptor; the xml source file information comprises the identification and storage path of the xml source file;

[0016] According to the method name of the SQL statement, the xml source file information of the SQL statement is stored, and the second dependency relationship between the methods contained in the data access layer bean and the xml source file information is determined;

[0017] According to the dependency classes of all levels corresponding to each control layer bean and the methods contained in the data access layer bean, the second dependency relationship corresponding to each data access layer bean, the dependency relationship between the classes and the xml source file information in the target project is determined.

[0018] Optionally, for any control layer bean in the target project, the dependency classes of all levels corresponding to the control layer bean are detected by using a recursive algorithm, and the method comprises the following steps:

[0019] For any target class, the second execution code corresponding to the target class is scanned by using an annotation; wherein the target class is the control layer bean or the dependency class of any level;

[0020] When the scanned annotation is a preset annotation, the code entity corresponding to the annotation is determined;

[0021] extracting, from the code entity, an identification and a type of a next-level dependent class;

[0022] determining, according to the identification and the type of the next-level dependent class, a third execution code corresponding to the next-level dependent class through a reflection mechanism of the class.

[0023] Optionally, extracting, from the code entity, the identification and the type of the next-level dependent class comprises:

[0024] determining, according to the code entity, an identification and a type of an alternative dependent class;

[0025] removing, from the alternative dependent class, a project framework and a class of a JAR package itself to obtain the identification and the type of the next-level dependent class.

[0026] Optionally, determining, according to all levels of dependent classes corresponding to each control layer bean and methods contained in data access layer beans, and a first dependency relationship corresponding to each data access layer bean, a dependency relationship between classes and library table information in the target project comprises:

[0027] obtaining a target project identification, an identification and a type of a to-be-queried bean input by a user, and determining, according to all levels of dependent classes corresponding to each control layer bean and methods contained in data access layer beans, and a first dependency relationship corresponding to each data access layer bean, a dependency tree of the to-be-queried bean through a for loop and a depth-first traversal processing loop dependency;

[0028] displaying, on a user interaction interface, a dependency tree of the to-be-queried bean, the dependency tree of the to-be-queried bean containing all levels of dependent classes and operation library tables.

[0029] In a second aspect, an embodiment of the present application provides a class and library table dependency relationship determining device, the device comprising:

[0030] a running module configured to run, for any data access layer bean in a target project, a first execution code corresponding to the data access layer bean, and determine, according to a SQL statement generated during running of the first execution code and a method name calling the SQL statement, a first dependency relationship between a method contained in the data access layer bean and library table information; wherein the library table information comprises an identification of the library table and a database identification to which the library table belongs; and the library table information is obtained by analyzing the SQL statement;

[0031] a detection module configured to detect, for any control layer bean in a target project, all levels of dependent classes corresponding to the control layer bean through a recursive algorithm, and determine a method contained in a data access layer bean when the dependent class is the data access layer bean.

[0032] The determining module is configured to determine the dependency relationship between the classes and the library table information in the target project according to the dependency classes and the methods contained in the data access layer beans of all the layers corresponding to each control layer bean, and the first dependency relationship corresponding to each data access layer bean.

[0033] In a third aspect, an electronic device is provided, including: a memory, a processor;

[0034] The memory stores computer-executable instructions.

[0035] The processor executes the computer-executable instructions stored in the memory, so that the processor executes any of the above aspects and various possible implementation manners.

[0036] In a fourth aspect, a computer-readable storage medium is provided, and the computer-readable storage medium stores computer-executable instructions. When the computer-executable instructions are executed by a processor, the computer-executable instructions are used to implement any of the above aspects and various possible implementation manners.

[0037] In a fifth aspect, a computer program product is provided, and the computer program product includes a computer program. When the computer program is executed by a processor, the computer program implements any of the above aspects and various possible implementation manners.

[0038] The method provided by the embodiment of the application comprises: running a first execution code corresponding to a data access layer bean in a target project; determining a first dependency relationship between a method included in the data access layer bean and library table information according to a SQL statement generated during running of the first execution code and a method name for calling the SQL statement; wherein the library table information comprises an identifier of the library table and an identifier of a database to which the library table belongs; the library table information is obtained by analyzing the SQL statement; for any control layer bean in the target project, detecting all levels of dependent classes of the control layer bean by using a recursive algorithm, and when the dependent class is a data access layer bean, determining a method included in the data access layer bean; determining a dependency relationship between classes and library table information in the target project according to all levels of dependent classes corresponding to each control layer bean and the method included in the data access layer bean, and the first dependency relationship corresponding to each data access layer bean. The application starts from a control layer bean, detects dependent classes of each level by using a recursive algorithm, and finds a data access layer bean finally executing a SQL and a method included in the data access layer bean. Then, the method included in the data access layer bean is related to specific library table information by using the first dependency relationship, to form a clear and accurate chain. According to the chain, the overall analysis efficiency can be improved, the probability of missing migration and incorrect migration can be reduced, and in terms of performance, the application has the advantages of low resource consumption, high efficiency, great saving of manpower, and the like. Meanwhile, in terms of reliability, the dependency relationship is more comprehensive and has higher accuracy. In terms of use cost, only Jar package dependency and simple configuration are needed, and a visual query interface is provided. BRIEF DESCRIPTION OF DRAWINGS

[0039] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the application and serve to explain the principles of the application.

[0040] Figure 1 An application scenario provided by the embodiment of the application;

[0041] Figure 2 A flowchart of a method for determining a dependency relationship between classes and library tables provided by the embodiment of the application;

[0042] Figure 3 A user interaction interface provided by the embodiment of the application;

[0043] Figure 4 A structure diagram of a device for determining a dependency relationship between classes and library tables provided by the application;

[0044] Figure 5 A structural schematic diagram of an electronic device provided in the present application is shown.

[0045] The specific embodiments of the present application have been shown and described in the above drawings, which will be described in more detail hereinafter. These drawings and the written description are not intended to restrict the scope of the present application concept in any way, but to illustrate the present application concept to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION

[0046] The exemplary embodiments will be described in detail herein with reference to the attached drawings. The following description is made with reference to the accompanying drawings in which like reference numerals refer to like elements, and the term "exemplary" is used herein to mean "serving as an example, instance, or illustration." The following description is not intended to limit the scope of the present application concept in any way, but rather to provide an example of how the present application concept can be implemented. The following description includes specific details for the purpose of providing a thorough understanding of the present application concept. However, it will be apparent to those skilled in the art that the present application concept can be practiced without these specific details.

[0047] In the technical solution of the present application, the collection, storage, use, processing, transmission, provision and disclosure of information such as financial data or user data comply with relevant laws and regulations and do not violate public order and good customs.

[0048] It should be noted that in the embodiments of the present application, some software, components, models and other existing solutions in the industry may be mentioned, which should be considered as exemplary, and the purpose is only to illustrate the feasibility of the implementation of the technical solution of the present application, but it does not mean that the applicant has or will necessarily use the solution.

[0049] Enterprise Java application systems, as an important carrier to support the core business of key industries such as finance, telecommunications, and energy, usually have typical characteristics such as large scale, complex functions, and high module coupling. Such systems often undergo business evolution and technical iteration for ten years or even longer, accumulating millions of lines of complex code libraries, forming a complex system including control layer, business logic layer, data access layer, and other multi-level architectures. There are usually a large number of business logic components, data access objects, service interfaces, and control layer components in the system, which are related to each other through complex calling relationships, forming a highly coupled mesh structure.

[0050] In the process of Xinxin migration or system reconstruction, this work not only involves the replacement or reconstruction of the underlying database, but also needs to be synchronized with the adaptation and reconstruction of all related Java codes. Due to historical reasons, many legacy systems have missing documents, incomplete annotations, or outdated updates, resulting in a large number of implicit and non-explicitly declared dependencies between database table structures and business code logic. More complex is that some dependencies are only triggered under certain business scenarios or runtime conditions, which further increases the difficulty of dependency identification.

[0051] Currently, the enterprise mainly relies on the manual code review and experience judgment of the developer to comb such implicit dependencies. This method has obvious limitations: the efficiency of manual combing is extremely low. In the face of massive code library, the developer needs to read and understand the code logic line by line, which not only consumes time and effort, but also is difficult to complete comprehensive analysis within the project specified period.

[0052] Therefore, the present application provides a method for determining the dependency relationship between classes and library tables. For any data access layer bean in the target project, the first execution code corresponding to the data access layer bean is run. The first dependency relationship between the methods contained in the data access layer bean and the library table information is determined according to the SQL (Structured Query Language) statements generated during the running of the first execution code and the method name calling the SQL statements. The library table information includes the identification of the library table and the database to which the library table belongs. The library table information is obtained by parsing the SQL statements. For any control layer bean in the target project, the recursive algorithm is used to detect all levels of dependent classes corresponding to the control layer bean, and when the dependent class is a data access layer bean, the method contained in the data access layer bean is determined. According to the dependent classes of all levels corresponding to each control layer bean and the methods contained in the data access layer bean, the first dependency relationship corresponding to each data access layer bean, the dependency relationship between classes and library table information in the target project is determined. The present application starts from the control layer bean and detects the dependent classes of each level by recursive algorithm, until the data access layer bean that finally executes the SQL is found, as well as the methods included in the data access layer bean. Then, through the first dependency relationship, the methods included in the data access layer bean are related to the specific library table information, forming a clear and accurate chain. According to the chain, the overall efficiency of analysis can be improved, and the probability of missing migration and wrong migration can be reduced. In terms of performance, it has the advantages of less resource consumption, high efficiency, and great saving of manpower. At the same time, in terms of reliability, the dependency relationship covers more comprehensively and has higher accuracy. In terms of use cost, only Jar package dependency and simple configuration are needed, and a visual query interface is provided.

[0053] Figure 1 An application scenario diagram provided by the embodiment of the present application is shown in Figure 1 As shown in the figure, the execution subject can be a Spring framework. For any data access layer bean in the target project, the Spring framework runs the first execution code corresponding to the data access layer bean, and generates the SQL statement during the running of the first execution code and the method name for calling the SQL statement. According to the generated SQL statement and the method name for calling the SQL statement, the Spring framework can determine the first dependency relationship between the method contained in the data access layer bean and the library table information. For any control layer bean in the target project, the Spring framework can detect all the dependency classes of the control layer bean corresponding to all levels by using a recursive algorithm, and when the detected dependency class is a data access layer bean, the method contained in the data access layer bean is determined. Finally, according to all the dependency classes of each control layer bean corresponding to all levels and the method contained in the data access layer bean, the first dependency relationship corresponding to each data access layer bean, the dependency relationship between the class and the library table information in the target project is determined.

[0054] The technical solutions of the present application and how the technical solutions of the present application solve the above technical problems will be described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes can not be described again in some embodiments. The embodiments of the present application will be described below with reference to the accompanying drawings.

[0055] Figure 2 A flowchart of a class and library table dependency relationship determination method provided by the embodiment of the present application. The execution subject of the embodiment can be any Java code environment that can run Java code. The present application will be described in detail with the Spring framework as an example. As shown in the figure, the class and library table dependency relationship determination method provided by the embodiment of the present application can include: Figure 2

[0056] Step 201, for any data access layer bean in the target project, running the first execution code corresponding to the data access layer bean; determining the first dependency relationship between the method contained in the data access layer bean and the library table information according to the SQL statement generated during the running of the first execution code and the method name for calling the SQL statement; wherein the library table information includes the identifier of the library table and the identifier of the database to which the library table belongs; the library table information is obtained by analyzing the SQL statement.

[0057] ​The application provides a class and library table dependency relationship determination method, which is packaged into a Jar package dependency in a Spring framework, the Jar package is introduced into the Spring framework and configuration is completed, and the Spring framework can automatically and deeply analyze the dependency relationship between classes and classes and between classes and library tables in a target project.

[0058] The target project can be a target Java project. The target project can include a data access layer bean, a control layer bean, and a service layer bean.

[0059] The control layer bean is used for receiving and responding to client requests, and does not process business logic, but is responsible for coordination, such as parsing request parameters, calling service layer beans for processing, and encapsulating return results.

[0060] The service layer bean includes the core business logic of the target project, and contains complex business rules, process arrangement, transaction management, and permission verification, etc. The service layer bean can call one or more data access layer methods to complete a task.

[0061] The data access layer bean is used for pure technical interaction with a database. The data access layer bean does not contain any business rules, but is responsible for performing add, delete, modify, and query operations, such as executing SQL, encapsulating result sets, and converting database records into Java objects.

[0062] The identifier of the library table refers to a name used to uniquely identify a table in a database management system (DBMS, Database Management System).

[0063] The database identifier is used for the unique identification of a database instance or a logical database.

[0064] The method name for calling the SQL statement is the SQL ID (Identifier), and the SQL ID is usually named according to the corresponding method name.

[0065] The first execution code refers to the code of the corresponding data access layer bean.

[0066] For any data access layer bean, run the unit test corresponding to the data access layer bean, the unit is used to test the first execution code corresponding to the data access layer bean, and the coverage of the unit test determines the completeness of the first dependency relationship extraction.

[0067] Optionally, the first dependency relationship between the methods included in the data access layer bean and the library table information can be stored in a table.

[0068] Optionally, the first dependency relationship between the method contained in the data access layer bean and the library table information is determined according to the SQL statement generated during the running of the first execution code and the method name for calling the SQL statement, and the method for calling the SQL statement.

[0069] During the running of the first execution code, the generated SQL statement and the method name for calling the SQL statement are intercepted by using an interceptor.

[0070] The SQL statement is parsed by using a Jsqlparser parser to obtain the library table information corresponding to the SQL statement.

[0071] The first dependency relationship between the method contained in the data access layer bean and the library table information is determined according to the method name for calling the SQL statement and the library table information corresponding to the SQL statement.

[0072] In the application, the specific form of the interceptor is not limited as long as the function of intercepting the generated SQL statement and the method name for calling the SQL statement can be achieved.

[0073] Specifically, during the running of the first execution code, the generated SQL statement and the method name for calling the SQL statement are intercepted by using an interceptor, and then for any intercepted SQL statement, the SQL statement is parsed by using a Jsqlparser parser to obtain the library table information corresponding to the SQL statement.

[0074] Since the intercepted SQL statement and the method name for calling the SQL statement are in a corresponding relationship, and the library table information corresponding to the SQL statement is obtained, the dependency relationship between the method name and the library table information can be determined, that is, the first dependency relationship between the method contained in the data access layer bean and the library table information is obtained.

[0075] In this way, the SQL statement finally executed during the real running is captured, the dependency relationship omission caused by code logic branching, dynamic SQL splicing or other running conditions is avoided, the determination efficiency of the dependency relationship is improved, and the accuracy and efficiency of determining the library table information are improved by using a special SQL parser (Jsqlparser) to deeply parse the intercepted original SQL string instead of simple string matching.

[0076] Step 202, for any control layer bean in the target project, the dependency classes of all levels corresponding to the control layer bean are detected by using a recursive algorithm, and when the dependency class is a data access layer bean, the method contained in the data access layer bean is determined.

[0077] Specifically, all the beans in the Spring container can be obtained by using the BeanFactory, and the control layer beans can be filtered by traversing.

[0078] For any control layer bean, the first level dependent class dependent on the control bean is detected, for any first level dependent class, the second level dependent class dependent on the first level dependent class is detected, for any second level dependent class, the third level dependent class dependent on the second level dependent class is detected, and so on, until the dependent class of the next level cannot be detected.

[0079] When the dependent class of a certain level is detected as a data access layer bean, the method contained in the data access layer bean is detected.

[0080] Optionally, for any control layer bean in the target project, the dependent classes of all levels corresponding to the control layer bean are detected by using a recursive algorithm, including:

[0081] For any target class, the second execution code corresponding to the target class is scanned by using an annotation, wherein the target class is the control layer bean or the dependent class of any level;

[0082] When the scanned annotation is a preset annotation, the code entity corresponding to the annotation is determined;

[0083] The identifier and type of the next level dependent class are extracted from the code entity;

[0084] According to the identifier and type of the next level dependent class, the third execution code corresponding to the next level dependent class is determined by using the reflection mechanism of the class.

[0085] Specifically, for any control layer bean in the target project, the annotations in the second execution code corresponding to the target class are scanned, and when the scanned annotation is a preset annotation, the code entity corresponding to the annotation is the code located in the next line of the annotation. The preset annotations are @Autowired, @Resource, and @Qualifier, wherein @Autowired is usually used alone, and @Resource and @Qualifier are usually combined.

[0086] The identifier and type of the next level dependent class can be extracted from the code entity corresponding to the preset annotation, and in general, the type of the next level dependent class is located before the identifier of the next level dependent class.

[0087] After obtaining the identifier and type of the next level dependent class, the third execution code corresponding to the next level dependent class can be determined by using the reflection mechanism of the class.

[0088] The same as the above steps, the annotations in the third execution code are scanned, when the scanned annotation is the preset annotation, the code entity corresponding to the annotation is determined, the identification and type of the next level dependent class are extracted from the code entity, and the execution code corresponding to the next level dependent class is determined according to the identification and type of the next level dependent class, until the preset annotation cannot be scanned, and all levels of dependent classes corresponding to the control layer bean are obtained.

[0089] And when the dependent class of a certain level is detected as a data access layer bean, the reflection mechanism of the class can be used to detect the method contained in the data access layer bean, so that the dependent relationship between the data access layer bean and the method is obtained.

[0090] According to the dependent classes of all levels corresponding to the control layer bean, and the dependent relationship between the data access layer bean and the method, a dependent relationship chain is obtained, the top of the chain is the control layer bean, and the bottom is the method corresponding to the data access layer bean.

[0091] For any control layer bean in the target project, all levels of dependent classes corresponding to the control layer bean are detected, and the method contained in the data access layer bean when the dependent class is the data access layer bean is stored in the table.

[0092] And for any level of dependent class, the type, full name, parent class name and the like corresponding to the dependent class are stored in the above table, wherein the parent class name corresponding to a certain dependent class is the class name of the class corresponding to the previous level, and there is no actual inheritance relationship, and it is only used for subsequent data construction tree structure.

[0093] The full name of the class refers to a complete string that can uniquely determine a class in the target project, which can be composed of a package name and a class name, and can be separated by a period, that is, the full name of the class includes not only the class name but also the entire path information of the package to which the class name belongs.

[0094] Optionally, the identification and type of the next level dependent class are extracted from the code entity, including:

[0095] The identification and type of the alternative dependent class are determined according to the code entity;

[0096] The project framework and the classes of the JAR package itself are removed from the alternative dependent class, and the identification and type of the next level dependent class are obtained.

[0097] Illustratively, the project framework can be a Spring framework,

[0098] Specifically, the Spring framework extracts the identification and type of the alternative dependent class from the code entity, removes the classes of the project framework itself and the classes of the JAR package itself from the alternative dependent class, and the identification and type of the alternative dependent class left after the removal are the identification and type of the next level dependent class.

[0099] The classes of the JAR package itself refer to other classes in the same JAR package to which the code entity being analyzed directly belongs.

[0100] In this way, through the strategy of extensive collection and accurate filtering, the original dependent information containing a large amount of technical infrastructure and implementation details is refined into a dependent list that purely represents the business design intent and core collaboration relationship, greatly improving the quality and usability of the dependent information.

[0101] In step 203, the dependency relationship between the classes and the library table information in the target project is determined according to the dependency classes and the data access layer beans containing the methods of all levels corresponding to each control layer bean, and the first dependency relationship corresponding to each data access layer bean.

[0102] Specifically, the dependency relationship between the methods included in any data access layer bean and the library table information, and the dependency relationship of all levels of any control layer bean, and the methods contained in the data access layer bean can determine the dependency relationship between the classes and the classes in the entire target project, and the dependency relationship between the classes and the library table information, wherein the dependency relationship between the classes and the library table information refers to the dependency relationship between the data access layer bean and the library table information, forming a complete chain.

[0103] The method for determining the class and library table dependency relationship provided in the application can run first execution code corresponding to a data access layer bean in any target project; determine a first dependency relationship between a method included in the data access layer bean and library table information according to a SQL statement generated during the running of the first execution code and a method name for calling the SQL statement; wherein the library table information comprises an identifier of the library table and an identifier of a database to which the library table belongs; the library table information is obtained by analyzing the SQL statement; for any control layer bean in the target project, a recursive algorithm is used to detect all levels of dependent classes corresponding to the control layer bean, and when the dependent class is a data access layer bean, a method included in the data access layer bean is determined; and the dependency relationship between the classes and the library table information in the target project is determined according to all levels of dependent classes corresponding to each control layer bean and the methods included in the data access layer beans, and the first dependency relationship corresponding to each data access layer bean.

[0104] Optionally, the dependency relationship between the classes and the library table information in the target project is determined according to all levels of dependent classes corresponding to each control layer bean and the methods included in the data access layer beans, and the first dependency relationship corresponding to each data access layer bean, and comprises:

[0105] The target project identifier, the identifier and the type of the bean to be queried input by the user are obtained, and a dependency tree of the bean to be queried is constructed by a for loop and a depth-first traversal processing loop dependency according to all levels of dependent classes corresponding to each control layer bean and the methods included in the data access layer beans, and the first dependency relationship corresponding to each data access layer bean.

[0106] The dependency tree of the bean to be queried is displayed on the user interaction interface, and the dependency tree of the bean to be queried comprises all levels of dependent classes and operation library tables.

[0107] Figure 3This is a schematic diagram of a user interface provided in an embodiment of this application, such as... Figure 3 The user can enter the name of the target project in the input box corresponding to the target project, and enter the type of the bean to be queried in the input box corresponding to the bean type. The type of the bean to be queried can include: control layer, data access layer, and service layer. In the two input boxes corresponding to the bean identifier, the left input box can be used to enter either the class name (name) or the fully qualified name (fullname) of the class. If the class name (name) is selected in the left input box, the actual name of the class can be entered in the right input box. If the fully qualified name (fullname) of the class is selected in the left input box, the actual fully qualified name of the class can be entered in the right input box.

[0108] If the bean to be queried is of the controller layer type, only the "Query Down" button will be clickable. Clicking the "Query Down" button will retrieve the dependency classes of all layers corresponding to the controller layer bean, as well as the XML source file, methods, and library table information of the underlying data access layer bean.

[0109] If the bean being queried is of type data access layer or server, both the "Query Down" and "Query Up" buttons will be clickable. Clicking "Query Down" will retrieve all dependency classes from the bean being queried to the underlying data access layer bean, as well as the corresponding XML source file, methods, and library table information for the underlying data access layer bean. Clicking "Query Down" will retrieve all dependency classes from the bean being queried to the top-level controller bean.

[0110] The query result in the figure is the dependency relationship of the bean to be queried, which is the bean of the type control layer and the name testAction. As shown in the table, the first level class is named testAction, the full name is com.bocom.demo.action.TestAction, the parent class is demo, and the class type is control layer; the second level class is named testService, the full name is com.bocom.demo.service.ITestService, the parent class is com.bocom.demo.action.TestAction, and the class type is service layer; the third level class is named testServicelmpl, the full name is com.bocom.demo.service.impl.TestservicelmplDAO, the parent class is com.bocom.demo.service.ITestService, and the class type is service layer; the fourth level class is named testDAO, the full name is com.bocom.demo.dao.ITestDao, the parent class is com.bocom.demo.service.impl.TestservicelmplDAO, and the class type is data access layer; the fifth level class is named testDaolmpl, the full name is com.bocom.demo.dao.impl.TestDaolmpl, the parent class is com.bocom.demo.dao.ITestDao, and the class type is data access layer; the sixth level class is named Mapper.xml, the full name is com.bocom.demo.dao.mapper.TestMapper, the parent class is com.bocom.demo.dao.impl.TestDaolmpl, and the class type is data access layer; the seventh level XML source file is named TestMapperxml, the full name is com.bocom.demo.dao.mapper\TestMapper.xml, the parent class is com.bocom.demo.dao.mapper.TestMapper, and the type is xml; and the eighth level SQL is named queryExists, the full name is demo.dao.mapper.TestMapper.queryExists, and the parent class is com.bocom.demo.dao.mapper\TestMapper.xml, type: SQL; the name of the ninth level is DEMO_DEPENDENCY, the full name is DEMO_DEPENDENCY, the parent class name is demo.dao.mapper.TestMapper.queryExistsTABLE, and the type is TABLE.

[0111] In this way, the accuracy and efficiency of determining the dependency relationship between the class and the library table information in the target project are improved by the above method.

[0112] Optionally, the method for determining the dependency relationship between the class and the library table provided in the application further comprises:

[0113] intercepting the xml source file information storing the SQL statement; the xml source file information includes the identifier and storage path of the xml source file;

[0114] storing the xml source file information of the SQL statement according to the method name of the SQL statement, and determining the second dependency relationship between the method contained by the data access layer bean and the xml source file information;

[0115] determining the dependency relationship between the class and the xml source file information in the target project according to the dependency classes of all levels corresponding to each control layer bean and the methods contained by the data access layer bean, and the second dependency relationship corresponding to each data access layer bean.

[0116] The xml source file information includes the identifier and storage path of the xml source file.

[0117] The method for determining the dependency relationship between the class and the library table provided in the application not only determines the first dependency relationship between the method contained by the data access layer bean and the library table information, but also determines the second dependency relationship between the method contained by the data access layer bean and the xml source file information. The second dependency relationship corresponding to each data access layer bean is associated with the dependency classes of all levels corresponding to each control layer bean and the methods contained by the data access layer bean, so that the dependency relationship between the class and the xml source file information in the target project can be obtained.

[0118] The following is another embodiment of the method for determining the dependency relationship between the class and the library table, which is described by taking the inventor's local demo project system (simple structure, complete class level, and only for example) as an example.

[0119] 1. Import the dependent Jar package and complete the configuration.

[0120] 2. Build a dependency relationship storage table in the database, such as the storage table mentioned in the above embodiment.

[0121] 3. Configure the switch, run all data access layer bean corresponding unit test.

[0122] 4. Configure the dependency relationship pull switch, start the demo project, the project is automatically pulled when it starts, and the project is successfully started.

[0123] 5. Access the front-end page, enter the key field, query the class to the library table dependency tree, and implement the results Figure 3 .

[0124] Corresponding to the above-mentioned class and library table dependency relationship determination method, the embodiment of the application further provides a class and library table dependency relationship determination device, Figure 4 The structure diagram of a class and library table dependency relationship determination device provided by the application is shown in Figure 4 The class and library table dependency relationship determination device provided by the embodiment comprises:

[0125] The running module 401 is configured to run the first execution code corresponding to any data access layer bean in the target project, determine the first dependency relationship between the method contained by the data access layer bean and the library table information according to the SQL statement generated during the running of the first execution code and the method name calling the SQL statement, wherein the library table information comprises the identifier of the library table and the database identifier to which the library table belongs; and the library table information is obtained by analyzing the SQL statement;

[0126] The detection module 402 is configured to detect all levels of dependent classes corresponding to any control layer bean in the target project through a recursive algorithm, and determine the method contained by the data access layer bean when the dependent class is a data access layer bean.

[0127] The determination module 403 is configured to determine the dependency relationship between the class and the library table information in the target project according to all levels of dependent classes corresponding to each control layer bean and the method contained by the data access layer bean, and the first dependency relationship corresponding to each data access layer bean.

[0128] Optionally, when the running module determines the first dependency relationship between the method contained by the data access layer bean and the library table information according to the SQL statement generated during the running of the first execution code and the method name calling the SQL statement, the running module is specifically configured to:

[0129] During the running of the first execution code, the generated SQL statement and the method name calling the SQL statement are intercepted by using an interceptor;

[0130] The SQL statement is parsed by using a Jsqlparser parser to obtain library table information corresponding to the SQL statement;

[0131] According to the method name of calling the SQL statement and the library table information corresponding to the SQL statement, a first dependency relationship between a method included in a data access layer bean and the library table information is determined.

[0132] Optionally, the running module 401 is further configured to:

[0133] The xml source file information in which the SQL statement is stored is intercepted by using an interceptor; the xml source file information includes an identifier and a storage path of the xml source file;

[0134] According to the method name of the SQL statement, the xml source file information of the SQL statement is stored, and a second dependency relationship between a method included in a data access layer bean and the xml source file information is determined.

[0135] According to the dependency classes of all levels corresponding to each control layer bean and the methods included in the data access layer bean, and the second dependency relationship corresponding to each data access layer bean, a dependency relationship between a class and the xml source file information in the target project is determined.

[0136] Optionally, when detecting, by using a recursive algorithm, all dependency classes of a level corresponding to any control layer bean in the target project, the detecting module 402 is specifically configured to:

[0137] For any target class, the second execution code corresponding to the target class is annotated and scanned; the target class is the control layer bean or a dependency class of any level;

[0138] When the scanned annotation is a preset annotation, a code entity corresponding to the annotation is determined;

[0139] From the code entity, an identifier and a type of a next-level dependency class are extracted;

[0140] According to the identifier and the type of the next-level dependency class, a third execution code corresponding to the next-level dependency class is determined by using a reflection mechanism of the class.

[0141] Optionally, when extracting, from the code entity, the identifier and the type of the next-level dependency class, the detecting module 402 is specifically configured to:

[0142] According to the code entity, an identifier and a type of a candidate dependency class are determined;

[0143] From the candidate dependency class, a class of a project framework and a class of a JAR package itself are removed, to obtain the identifier and the type of the next-level dependency class.

[0144] Optionally, the determining module 403 is specifically configured to:

[0145] obtain the target project identifier, the identifier of the to-be-queried bean, and the type input by the user, construct a dependency tree of each data access layer bean according to all the levels of dependency classes corresponding to each control layer bean and the methods contained in the data access layer bean, and process the circular dependency by using a depth-first traversal method according to the first dependency relationship corresponding to each data access layer bean;

[0146] display the dependency tree of the to-be-queried bean in a user interaction interface, wherein the dependency tree of the to-be-queried bean contains the dependency classes of all the levels and the operation library table.

[0147] The class and library table dependency relationship determining apparatus provided in this embodiment can execute the method provided in the method embodiment, and has similar implementation principles and technical effects, which will not be described here in detail.

[0148] Figure 5 The structure of the electronic device provided in this application is shown in FIG. 1. Figure 5 As shown in FIG. 1, the electronic device 50 provided in this embodiment includes at least one processor 501 and a memory 502. Optionally, the device 50 further includes a communication component 503. The processor 501, the memory 502, and the communication component 503 are connected through a bus 504.

[0149] In the specific implementation process, the at least one processor 501 executes the computer execution instructions stored in the memory 502, so that the at least one processor 501 executes the method described above.

[0150] The specific implementation process of the processor 501 can refer to the method embodiment described above, which has similar implementation principles and technical effects, and will not be described here in detail.

[0151] In the above embodiments, it should be understood that the processor can be a central processing unit (CPU), and can also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in the application can be directly embodied as execution completed by a hardware processor, or executed by a combination of hardware and software modules in the processor.

[0152] The memory may include random access memory (RAM) and may also include non-volatile memory (NVM), such as at least one disk storage device.

[0153] The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of illustration, the buses shown in the accompanying drawings are not limited to a single bus or a single type of bus.

[0154] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the above-described method.

[0155] This application also provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the above-described method.

[0156] The aforementioned readable storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. The readable storage medium can be any available medium accessible to a general-purpose or special-purpose computer.

[0157] An exemplary readable storage medium is coupled to a processor, enabling the processor to read information from and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can reside in an Application Specific Integrated Circuit (ASIC). Alternatively, the processor and the readable storage medium can exist as discrete components in the device.

[0158] The division of units is merely a logical functional division; in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be indirect coupling or communication connection through some interfaces, devices, or units, and may be electrical, mechanical, or other forms.

[0159] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0160] In addition, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0161] If a function is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0162] Those skilled in the art will understand that all or part of the steps of the above-described method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When executed, the program performs the steps of the above-described method embodiments; and the aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.

[0163] Finally, it should be noted that other embodiments of the invention will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This invention is intended to cover any variations, uses, or adaptations of the invention that follow the general principles of the invention and include common knowledge or customary techniques in the art not disclosed herein, and is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of the invention is limited only by the appended claims.

Claims

1. A method of determining class and library table dependencies, comprising: The method comprises: For any data access layer bean in the target project, running the first execution code corresponding to the data access layer bean; determining the first dependency relationship between the method contained by the data access layer bean and the library table information according to the SQL statement generated during the running of the first execution code and the method name calling the SQL statement; wherein the library table information comprises the identification of the library table and the database identification to which the library table belongs; the library table information is obtained by parsing the SQL statement; For any control layer bean in the target project, detecting all levels of dependent classes corresponding to the control layer bean by a recursive algorithm, and determining the method contained by the data access layer bean when the dependent class is a data access layer bean; According to all levels of dependent classes corresponding to each control layer bean and the method contained by the data access layer bean, and the first dependency relationship corresponding to each data access layer bean, the dependency relationship between the class and the library table information in the target project is determined.

2. The method of claim 1, wherein, According to the SQL statement generated during the running of the first execution code and the method name calling the SQL statement, the first dependency relationship between the method contained by the data access layer bean and the library table information is determined, comprising: During the running of the first execution code, the generated SQL statement and the method name calling the SQL statement are intercepted by an interceptor; The SQL statement is parsed by a Jsqlparser parser to obtain the library table information corresponding to the SQL statement; According to the method name calling the SQL statement and the library table information corresponding to the SQL statement, the first dependency relationship between the method contained by the data access layer bean and the library table information is determined.

3. The method of claim 2, wherein, The method further comprises: The xml source file information storing the SQL statement is intercepted by an interceptor; the xml source file information comprises the identification and storage path of the xml source file; According to the method name of the SQL statement, the xml source file information of the SQL statement is stored to determine the second dependency relationship between the method contained by the data access layer bean and the xml source file information; According to all levels of dependent classes corresponding to each control layer bean and the method contained by the data access layer bean, and the second dependency relationship corresponding to each data access layer bean, the dependency relationship between the class and the xml source file information in the target project is determined.

4. The method of claim 1, wherein, For any control layer bean in the target project, all levels of dependent classes corresponding to the control layer bean are detected by a recursive algorithm, comprising: For any target class, the second execution code corresponding to the target class is scanned by annotation; wherein the target class is the control layer bean or the dependent class of any level; When the scanned annotation is a preset annotation, the code entity corresponding to the annotation is determined; From the code entity, the identification and type of the next level dependent class are extracted; According to the identification and type of the next level dependent class, the third execution code corresponding to the next level dependent class is determined by the reflection mechanism of the class.

5. The method of claim 4, wherein, From the code entity, extract the next level of dependent class identification and type, including: According to the code entity, determine the identification and type of the alternative dependent class; From the alternative dependent class, remove the project framework and the class of the JAR package itself, to obtain the identification and type of the next level of dependent class.

6. The method according to any one of claims 1 to 5, characterized in that, According to the dependent classes of all levels corresponding to each control layer bean and the methods contained in the data access layer bean, the first dependency relationship corresponding to each data access layer bean, determine the dependency relationship between the classes and the library table information in the target project, including: Obtain the target project identification, the identification and type of the to-be-queried bean input by the user, according to the dependent classes of all levels corresponding to each control layer bean and the methods contained in the data access layer bean, the first dependency relationship corresponding to each data access layer bean, build its dependency tree through for loop and use depth-first traversal to process circular dependency; Display the dependency tree of the to-be-queried bean in the user interaction interface, the dependency tree of the to-be-queried bean contains the dependent classes of all levels and the operation library table.

7. An apparatus for determining class and library table dependency, the apparatus comprising: a class table; a library table; a class table dependency table; a library table dependency table; and a dependency determination module. The device comprises: A running module configured to run the first execution code corresponding to any data access layer bean in the target project, and determine the first dependency relationship between the methods contained in the data access layer bean and the library table information according to the SQL statement generated during the running of the first execution code and the method name calling the SQL statement; wherein the library table information comprises the identification of the library table and the database identification to which the library table belongs; the library table information is obtained by parsing the SQL statement; A detection module configured to detect the dependent classes of all levels corresponding to any control layer bean in the target project through recursive algorithm, and determine the methods contained in the data access layer bean when the dependent class is a data access layer bean; A determination module configured to determine the dependency relationship between the classes and the library table information in the target project according to the dependent classes of all levels corresponding to each control layer bean and the methods contained in the data access layer bean, and the first dependency relationship corresponding to each data access layer bean.

8. An electronic device, comprising: Comprise: Memory, processor; The memory stores computer execution instructions; The processor executes the computer execution instructions stored in the memory, so that the processor executes the method of any one of claims 1-6.

9. A computer-readable storage medium, characterized in that, The computer readable storage medium stores computer execution instructions, and the computer execution instructions are executed by the processor to implement the method of any one of claims 1-6.

10. A computer program product, characterised in that, The computer program is executed by the processor to implement the method of any one of claims 1-6. The computer program is executed by the processor to implement the method of any one of claims 1-6.