Jar package conflict detection method and device, storage medium and computer device

CN115563010BActive Publication Date: 2026-09-25VIPSHOP (GUANGZHOU) SOFTWARE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211330163.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-10-27
Publication Date
2026-09-25
Estimated Expiration
2042-10-27

AI Technical Summary

Technical Problem

[0004]但在测试过程中,并非所有包冲突都需要及时进行处理,若将所有包冲突都提示测试人员,会影响测试人员的测试效率

Benefits of technology

[0046]本申请提供的Jar包冲突检测方法、装置、存储介质及计算机设备,在满足触发条件时,确定当前需要进行检测的目标应用,根据目标应用确定其对应的Jar包目录,扫描Jar包目录中各Jar包的每个类,识别是否存在依赖相同路径下相同类名的类的Jar包,若存在,则将依赖相同路径下相同类名的类的Jar包确定为存在包冲突,对每组存在包冲突的Jar包进行检测,检测引发包冲突的被调用方法,对目标应用的增量代码进行判断,判断是否存在检测出的引发包冲突的被调用方法,若存在,则表明是增量代码引发了包冲突,需要及时进行处理,此时则生成冲突告警,能够快速检测包冲突并对包冲突进行过滤,对于需要及时处理的包冲突才触发告警,减少测试排查工作量。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115563010B_ABST
    Figure CN115563010B_ABST
Patent Text Reader

Abstract

The application provides a Jar package conflict detection method and device, a storage medium and a computer device. The method comprises the following steps: when a trigger condition is met, determining a target application; determining a Jar package directory corresponding to the target application; scanning each class of each Jar package in the Jar package directory; if there is a Jar package depending on a class with the same class name in the same path, it is determined that the Jar package depending on the class with the same class name in the same path has a package conflict; detecting a called method causing the package conflict in each group of Jar packages having the package conflict; obtaining an incremental code of the target application, and judging whether the incremental code contains the called method causing the package conflict; if the incremental code contains the called method causing the package conflict, a conflict alarm is generated. The application can quickly detect and filter package conflicts, and only triggers an alarm for the package conflicts that need to be handled in time, thereby reducing the workload of testing and troubleshooting.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of software development technology, and in particular to a method, apparatus, storage medium, and computer device for detecting Jar package conflicts. Background Technology

[0002] In the development process of a software application project, a large number of class files are usually involved. For ease of storage and use, they are usually packaged as JAR files. A JAR (Java Archive) package is a compressed package of Java files, which can also be considered as a collection of class files. To use a JAR package in a project, the path of the JAR package needs to be set in the relevant parameters used to specify the class loading path. The virtual machine can then dynamically load the classes contained in the JAR package at runtime.

[0003] If the version numbers of the code libraries and resource packages called during the development of different parts of a project are inconsistent, the virtual machine will load one of the classes when running Java code. This may result in errors such as a missing method call or member variable, leading to a runtime exception. This situation is called a package conflict.

[0004] However, not all packet conflicts need to be handled in a timely manner during testing. Notifying testers of all packet conflicts would affect their testing efficiency. Summary of the Invention

[0005] This application provides a method, apparatus, storage medium, and computer device for detecting Jar packet conflicts, which can quickly detect and filter packet conflicts, and only trigger alarms for packet conflicts that require timely handling, thereby reducing the workload of testing and troubleshooting.

[0006] Firstly, this application provides a method for detecting Jar package conflicts, the method comprising:

[0007] When the triggering conditions are met, the target application is identified;

[0008] Determine the JAR package directory corresponding to the target application;

[0009] Scan each class in each Jar package in the Jar package directory. If there is a Jar package that depends on a class with the same name in the same path, then it is determined that there is a package conflict between the Jar packages that depend on the class with the same name in the same path.

[0010] Detect the invoked method that caused the package conflict in each group of Jar packages;

[0011] Obtain the incremental code of the target application and determine whether the incremental code contains a called method that causes a package conflict;

[0012] If the incremental code contains a called method that causes a package conflict, a conflict alert is generated.

[0013] In one embodiment, the method invoked to detect the packet conflict in each group of Jar packages includes:

[0014] Read a group of JAR files that depend on classes with the same class name in the same path and generate a class file corresponding to each JAR file to be detected;

[0015] Decompile the class file corresponding to each Jar package to be detected into a Java file;

[0016] Based on the Java file corresponding to each Jar package to be detected, obtain all the called methods in each Jar package to be detected, and generate a method set corresponding to each Jar package to be detected;

[0017] The method sets of each Jar package to be tested are compared, and the code corresponding to the called methods that differ in each method set is identified and saved.

[0018] In one embodiment, the comparison of the method set of each Jar package to be detected, identifying and saving the code corresponding to the called methods that differ in each method set, includes:

[0019] Take the intersection of all the Jar packets to be detected to obtain the intersection result;

[0020] Take the difference between each Jar package to be detected and the intersection result to obtain the code corresponding to the called method that has differences in each Jar package to be detected, and save it.

[0021] In one embodiment, the method invoked to detect the packet conflict in each group of Jar packages includes:

[0022] The detection order is obtained by sorting the groups of Jar packets with packet conflicts according to the preset priority.

[0023] According to the detection order, the called methods that caused the package conflict in each group of Jar packages with package conflicts are detected sequentially.

[0024] In one embodiment, determining the Jar package directory corresponding to the target application includes:

[0025] Identify the application type of the target application;

[0026] The scanning path of the target application is determined based on the correspondence between application type and application path;

[0027] The Jar package directory under the scan route is determined as the Jar package directory corresponding to the target application.

[0028] In one embodiment, determining the target application when the triggering condition is met includes:

[0029] When it is confirmed that the application has been successfully deployed and the application status is available, the application is identified as the target application;

[0030] or

[0031] Upon receiving a detection instruction, the target application is determined based on the detection instruction.

[0032] In one embodiment, the method further includes:

[0033] The personnel who receive the alerts will be identified based on the target application.

[0034] The conflict alert is sent to the alerting personnel.

[0035] Secondly, this application provides a Jar packet conflict detection device, comprising:

[0036] The first determination module is used to determine the target application when the triggering conditions are met;

[0037] The second determining module is used to determine the Jar package directory corresponding to the target application;

[0038] The scanning module is used to scan each class in each Jar package in the Jar package directory. If there is a Jar package that depends on a class with the same name in the same path, it is determined that there is a package conflict between the Jar packages that depend on the class with the same name in the same path.

[0039] The detection module is used to detect the called methods that cause package conflicts in each group of Jar packages;

[0040] The code judgment module is used to obtain the incremental code of the target application and determine whether the incremental code contains a called method that causes a package conflict.

[0041] An alarm generation module is used to generate a conflict alarm when the incremental code contains a called method that causes a package conflict.

[0042] Thirdly, this application provides a storage medium storing computer-readable instructions that, when executed by one or more processors, cause the one or more processors to perform the steps of the Jar packet conflict detection method as described in any of the above embodiments.

[0043] Fourthly, this application provides a computer device, including: one or more processors, and a memory;

[0044] The memory stores computer-readable instructions, and when the one or more processors execute the computer-readable instructions, they perform the steps of the Jar packet conflict detection method as described in any of the above embodiments.

[0045] As can be seen from the above technical solutions, the embodiments of this application have the following advantages:

[0046] The Jar package conflict detection method, apparatus, storage medium, and computer equipment provided in this application, when the triggering conditions are met, determine the target application that needs to be detected, determine the corresponding Jar package directory based on the target application, scan each class of each Jar package in the Jar package directory, identify whether there are Jar packages that depend on classes with the same class name under the same path, if so, determine that there is a package conflict, detect each group of Jar packages with package conflicts, detect the called methods that cause package conflicts, judge the incremental code of the target application, determine whether there are any detected called methods that cause package conflicts, if so, it indicates that the incremental code caused the package conflict and needs to be handled in time, at which point a conflict alarm is generated, which can quickly detect and filter package conflicts, and only trigger alarms for package conflicts that need to be handled in time, reducing the workload of testing and investigation. Attached Figure Description

[0047] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0048] Figure 1 This is a flowchart illustrating a Jar packet conflict detection method in one embodiment.

[0049] Figure 2 This is a flowchart illustrating the steps of the called method that caused the package conflict in each group of Jar packages where a package conflict exists, as shown in one embodiment.

[0050] Figure 3 This is a structural block diagram of a Jar packet collision detection device in one embodiment;

[0051] Figure 4 This is a diagram of the internal structure of a computer device in one embodiment. Detailed Implementation

[0052] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.

[0053] like Figure 1 As shown, this application provides a method for detecting Jar packet conflicts, the method including steps S101 to S107, wherein:

[0054] Step S101: When the triggering condition is met, determine the target application.

[0055] The target application refers to the application that requires JAR package conflict detection. In one embodiment, when the application is detected as successfully deployed and its status is available, the application is identified as the target application; that is, when the application is successfully deployed and its status is detected as available, detection of the application is automatically triggered. In another embodiment, upon receiving a detection command, the target application is determined according to the detection command; that is, based on the received detection command, detection of the application specified by the detection command is passively triggered.

[0056] Step S102: Determine the Jar package directory corresponding to the target application.

[0057] The corresponding JAR file directory can be obtained based on the class loading path of the target application.

[0058] In one embodiment, determining the Jar package directory corresponding to the target application includes: identifying the application type of the target application; determining the scanning path of the target application based on the correspondence between application type and application path; and determining the Jar package directory under the scanning path as the Jar package directory corresponding to the target application. Different application types will be configured with different loading paths. Determining the loading path corresponding to the application type of the target application first can improve the scanning efficiency.

[0059] Step S103: Scan each class in each Jar package in the Jar package directory. If there is a Jar package that depends on a class with the same name in the same path, it is determined that there is a package conflict between the Jar packages that depend on the class with the same name in the same path.

[0060] Conflicts can occur when different versions of the same JAR file or when the same class appears in different JAR files. This can prevent the application from loading the correct class at runtime, leading to unexpected behavior. By scanning for JAR files that depend on classes with the same name located in the same path, conflicting JAR files can be initially identified. During the scan, classes contained in only one JAR file can be filtered out first, and then the remaining classes can be scanned.

[0061] Step S104: Detect the called method that caused the package conflict in each group of Jar packages where package conflicts exist.

[0062] This means detecting conflicting called methods, specifically methods in JAR files that cause loading errors due to package conflicts. Examples include different versions of the same method, or different types of the same method. Different types of the same method include methods with the same name and return type but different parameter types, and methods with the same name and parameter types but different return types.

[0063] Step S105: Obtain the incremental code of the target application and determine whether the incremental code contains a called method that causes a package conflict.

[0064] Incremental code refers to the new parts added to the target application compared to the previous modified code. This can be achieved by recording and comparing code submissions made by engineers each time. Determining whether incremental code contains called methods that could cause package conflicts can be done by detecting the presence of such methods within the incremental code. This can be done through methods such as identifying method names and performing regular expression analysis on the incremental code.

[0065] Step S106: If the incremental code contains a called method that causes a package conflict, a conflict alarm is generated.

[0066] Step S107: If the incremental code does not contain a called method that causes a package conflict, then no conflict alarm is generated.

[0067] Package conflicts caused by incremental code need to be handled promptly. Therefore, if the incremental code contains the called method that causes the package conflict, a conflict alert is generated to notify the testers. Package conflicts not caused by incremental code are filtered out and not alerted, or alerted in other low-priority ways, so that testers can prioritize handling package conflicts caused by incremental code, thereby reducing the workload of testing and troubleshooting.

[0068] In this embodiment, when the triggering condition is met, the target application that needs to be detected is determined. Based on the target application, its corresponding Jar package directory is determined. Each class in each Jar package in the Jar package directory is scanned to identify whether there are Jar packages that depend on classes with the same class name under the same path. If so, the Jar packages that depend on classes with the same class name under the same path are identified as having package conflicts. Each group of Jar packages with package conflicts is detected, and the called methods that cause package conflicts are detected. The incremental code of the target application is judged to determine whether there are any detected called methods that cause package conflicts. If so, it indicates that the incremental code caused the package conflict and needs to be handled in time. At this time, a conflict alarm is generated, which can quickly detect and filter package conflicts. Alarms are only triggered for package conflicts that need to be handled in time, reducing the workload of testing and investigation.

[0069] like Figure 2 As shown, in one embodiment, the method for detecting packet conflicts in each group of Jar packets includes steps S201 to S204, wherein:

[0070] Step S201: Read a group of Jar packages to be detected that depend on classes with the same class name under the same path, and generate a class file corresponding to each Jar package to be detected.

[0071] Each JAR file to be tested is read to obtain a class input stream. The input stream is then written to the directory of the local container to generate the class file for each JAR file to be tested.

[0072] Step S202: Decompile the class file corresponding to each Jar package to be detected into a Java file.

[0073] Use the javap command to decompile a class file into a Java file.

[0074] Step S203: Based on the Java file corresponding to each Jar package to be detected, obtain all the called methods in each Jar package to be detected, and generate a method set corresponding to each Jar package to be detected.

[0075] Read each Java file, identify all the called methods within it, and summarize the code of the called methods in each Java file to generate a method set corresponding to each Jar package to be detected.

[0076] Step S204: Compare the method sets of each Jar package to be detected, identify and save the code corresponding to the called methods that have differences in each method set.

[0077] Set operations are used to identify conflicting called methods, including different versions of the same method or different types of the same method. The differences between the conflicting called methods cause conflicts in JAR files, preventing correct class loading. Aside from the conflicting called method, the rest of the code in the conflicting JAR files should be identical. Therefore, set operations can be used to identify and save the differing parts. These saved conflicting called methods can be sent to testers along with conflict alerts for quick handling.

[0078] In one embodiment, the comparison of the method set of each Jar package to be detected, identifying and saving the code corresponding to the called methods that differ in each method set, includes:

[0079] Take the intersection of all the Jar packets to be detected to obtain the intersection result;

[0080] Take the difference between each Jar package to be detected and the intersection result to obtain the code corresponding to the called method that has differences in each Jar package to be detected, and save it.

[0081] In this embodiment, an intersection operation is performed on a group of Jar packages to be detected. The intersection result represents the called methods that are the same. Then, based on the intersection result, the difference between each Jar package to be detected and the intersection result is taken. The difference portion represents the called methods that differ between the Jar packages to be detected. The difference result obtained for each Jar package to be detected is saved. In this way, the detection range of conflicting methods can be expanded, and Jar packages with the same signature but conflicting relationships that cannot be detected by conventional detection methods can be detected.

[0082] In one embodiment, the method invoked to detect the packet conflict in each group of Jar packages includes:

[0083] The detection order is obtained by sorting the groups of Jar packets with packet conflicts according to the preset priority.

[0084] According to the detection order, the called methods that caused the package conflict in each group of Jar packages with package conflicts are detected sequentially.

[0085] In this embodiment, by configuring the detection priority, the Jar packages are detected in order of priority, reducing the number of concurrent detections. For Jar packages with lower priority, the detection is delayed, shortening the scanning time for key Jar packages and improving testing efficiency.

[0086] In one embodiment, the method further includes:

[0087] The personnel who receive the alerts will be identified based on the target application.

[0088] The conflict alert is sent to the alerting personnel.

[0089] In this implementation, alarm personnel who receive alarms can be pre-configured. Specifically, alarm personnel can be configured on a domain-by-domain basis, and conflict alarms can be sent to the corresponding alarm personnel according to the domain to which the target application belongs. In some embodiments, the correspondence between alarm personnel and applications can also be configured according to other rules, so that when a conflict alarm is generated, it can be sent to the test personnel who need to pay attention to the conflict.

[0090] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.

[0091] The Jar packet conflict detection device provided in the embodiments of this application is described below. The Jar packet conflict detection device described below can be referred to in correspondence with the Jar packet conflict detection method described above.

[0092] like Figure 3 As shown, this application embodiment provides a Jar packet conflict detection device 300, including:

[0093] The first determining module 301 is used to determine the target application when the triggering conditions are met;

[0094] The second determining module 302 is used to determine the Jar package directory corresponding to the target application;

[0095] The scanning module 303 is used to scan each class in each Jar package in the Jar package directory. If there is a Jar package that depends on a class with the same name in the same path, it is determined that there is a package conflict between the Jar packages that depend on the class with the same name in the same path.

[0096] The detection module 304 is used to detect the called methods that cause package conflicts in each group of Jar packages where package conflicts exist;

[0097] The code judgment module 305 is used to obtain the incremental code of the target application and determine whether the incremental code contains a called method that causes a package conflict.

[0098] The alarm generation module 306 is used to generate a conflict alarm when the incremental code contains a called method that causes a package conflict.

[0099] In one embodiment, the detection module includes:

[0100] The Class file generation unit is used to read a group of Jar packages to be detected that depend on classes with the same class name under the same path, and generate a class file corresponding to each Jar package to be detected.

[0101] The decompilation unit is used to decompile the class file corresponding to each Jar package to be detected into a Java file;

[0102] The collection generation unit is used to obtain all the called methods in each Jar file to be detected based on the Java file corresponding to each Jar file to be detected, and generate a method collection corresponding to each Jar file to be detected;

[0103] The identification unit is used to compare the method set of each Jar package to be detected, identify the code corresponding to the called method that has differences in each method set, and save it.

[0104] In one embodiment, the identification unit is configured to perform the following steps:

[0105] Take the intersection of all the Jar packets to be detected to obtain the intersection result;

[0106] Take the difference between each Jar package to be detected and the intersection result to obtain the code corresponding to the called method that has differences in each Jar package to be detected, and save it.

[0107] In one embodiment, the detection module includes:

[0108] The sorting unit is used to sort the groups of Jar packets with packet conflicts according to a preset priority to obtain the detection order;

[0109] The method detection unit is used to sequentially detect the called methods that cause package conflicts in each group of Jar packages that have package conflicts, according to the detection order.

[0110] In one embodiment, the first determining module is configured to perform the following steps:

[0111] When it is confirmed that the application has been successfully deployed and the application status is available, the application is identified as the target application;

[0112] or

[0113] Upon receiving a detection instruction, the target application is determined based on the detection instruction.

[0114] In one embodiment, the second determining module is configured to perform the following steps:

[0115] Identify the application type of the target application;

[0116] The scanning path of the target application is determined based on the correspondence between application type and application path;

[0117] The Jar package directory under the scan route is determined as the Jar package directory corresponding to the target application.

[0118] In one embodiment, the Jar packet collision detection device further includes:

[0119] The third determination module is used to determine the alarm personnel based on the target application;

[0120] The alarm sending module is used to send the conflict alarm to the alarm personnel.

[0121] The division of modules in the above-described Jar packet conflict detection device is merely illustrative. In other embodiments, the Jar packet conflict detection device can be divided into different modules as needed to complete all or part of its functions. Each module in the above-described Jar packet conflict detection device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device in hardware form, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.

[0122] In one embodiment, this application also provides a storage medium storing computer-readable instructions that, when executed by one or more processors, cause the one or more processors to perform the following steps:

[0123] When the triggering conditions are met, the target application is identified;

[0124] Determine the JAR package directory corresponding to the target application;

[0125] Scan each class in each Jar package in the Jar package directory. If there is a Jar package that depends on a class with the same name in the same path, then it is determined that there is a package conflict between the Jar packages that depend on the class with the same name in the same path.

[0126] Detect the invoked method that caused the package conflict in each group of Jar packages;

[0127] Obtain the incremental code of the target application and determine whether the incremental code contains a called method that causes a package conflict;

[0128] If the incremental code contains a called method that causes a package conflict, a conflict alert is generated.

[0129] In one embodiment, the computer-readable instructions, when executed by the processor, further perform the following steps:

[0130] Read a group of JAR files that depend on classes with the same class name in the same path and generate a class file corresponding to each JAR file to be detected;

[0131] Decompile the class file corresponding to each Jar package to be detected into a Java file;

[0132] Based on the Java file corresponding to each Jar package to be detected, obtain all the called methods in each Jar package to be detected, and generate a method set corresponding to each Jar package to be detected;

[0133] The method sets of each Jar package to be tested are compared, and the code corresponding to the called methods that differ in each method set is identified and saved.

[0134] In one embodiment, the computer-readable instructions, when executed by the processor, further perform the following steps:

[0135] Take the intersection of all the Jar packets to be detected to obtain the intersection result;

[0136] Take the difference between each Jar package to be detected and the intersection result to obtain the code corresponding to the called method that has differences in each Jar package to be detected, and save it.

[0137] In one embodiment, the computer-readable instructions, when executed by the processor, further perform the following steps:

[0138] The detection order is obtained by sorting the groups of Jar packets with packet conflicts according to the preset priority.

[0139] According to the detection order, the called methods that caused the package conflict in each group of Jar packages with package conflicts are detected sequentially.

[0140] In one embodiment, the computer-readable instructions, when executed by the processor, further perform the following steps:

[0141] Identify the application type of the target application;

[0142] The scanning path of the target application is determined based on the correspondence between application type and application path;

[0143] The Jar package directory under the scan route is determined as the Jar package directory corresponding to the target application.

[0144] In one embodiment, the computer-readable instructions, when executed by the processor, further perform the following steps:

[0145] When it is confirmed that the application has been successfully deployed and the application status is available, the application is identified as the target application;

[0146] or

[0147] Upon receiving a detection instruction, the target application is determined based on the detection instruction.

[0148] In one embodiment, the computer-readable instructions, when executed by the processor, further perform the following steps:

[0149] The personnel who receive the alerts will be identified based on the target application.

[0150] The conflict alert is sent to the alerting personnel.

[0151] In one embodiment, this application also provides a computer device storing computer-readable instructions, wherein when the one or more processors execute the computer-readable instructions, they perform the following steps:

[0152] When the triggering conditions are met, the target application is identified;

[0153] Determine the JAR package directory corresponding to the target application;

[0154] Scan each class in each Jar package in the Jar package directory. If there is a Jar package that depends on a class with the same name in the same path, then it is determined that there is a package conflict between the Jar packages that depend on the class with the same name in the same path.

[0155] Detect the invoked method that caused the package conflict in each group of Jar packages;

[0156] Obtain the incremental code of the target application and determine whether the incremental code contains a called method that causes a package conflict;

[0157] If the incremental code contains a called method that causes a package conflict, a conflict alert is generated.

[0158] In one embodiment, the processor also performs the following steps when executing computer-readable instructions:

[0159] Read a group of JAR files that depend on classes with the same class name in the same path and generate a class file corresponding to each JAR file to be detected;

[0160] Decompile the class file corresponding to each Jar package to be detected into a Java file;

[0161] Based on the Java file corresponding to each Jar package to be detected, obtain all the called methods in each Jar package to be detected, and generate a method set corresponding to each Jar package to be detected;

[0162] The method sets of each Jar package to be tested are compared, and the code corresponding to the called methods that differ in each method set is identified and saved.

[0163] In one embodiment, the processor also performs the following steps when executing computer-readable instructions:

[0164] Take the intersection of all the Jar packets to be detected to obtain the intersection result;

[0165] Take the difference between each Jar package to be detected and the intersection result to obtain the code corresponding to the called method that has differences in each Jar package to be detected, and save it.

[0166] In one embodiment, the processor also performs the following steps when executing computer-readable instructions:

[0167] The detection order is obtained by sorting the groups of Jar packets with packet conflicts according to the preset priority.

[0168] According to the detection order, the called methods that caused the package conflict in each group of Jar packages with package conflicts are detected sequentially.

[0169] In one embodiment, the processor also performs the following steps when executing computer-readable instructions:

[0170] Identify the application type of the target application;

[0171] The scanning path of the target application is determined based on the correspondence between application type and application path;

[0172] The Jar package directory under the scan route is determined as the Jar package directory corresponding to the target application.

[0173] In one embodiment, the processor also performs the following steps when executing computer-readable instructions:

[0174] When it is confirmed that the application has been successfully deployed and the application status is available, the application is identified as the target application;

[0175] or

[0176] Upon receiving a detection instruction, the target application is determined based on the detection instruction.

[0177] In one embodiment, the processor also performs the following steps when executing computer-readable instructions:

[0178] Identify the personnel who will trigger the alert based on the target application;

[0179] The conflict alert is sent to the alerting personnel.

[0180] In one embodiment, schematically, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 4 As shown, the computer device includes a processor, memory, and a network interface connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores data. The network interface communicates with external terminals via a network connection. When executed by the processor, the computer program implements a Jar packet conflict detection method.

[0181] Those skilled in the art will understand that Figure 4 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0182] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.

[0183] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0184] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this application, "multiple" means at least two, such as two, three, etc., unless otherwise explicitly specified.

[0185] The various embodiments in this specification are described in a progressive manner. Each embodiment focuses on the differences from other embodiments. The various embodiments can be combined as needed, and the same or similar parts can be referred to each other.

[0186] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method for detecting conflicts in Jar packets, characterized in that, The method includes: When the triggering conditions are met, the target application is determined, specifically including: when the application is detected to have been successfully deployed and the application status is available, the application is determined as the target application; or when a detection instruction is received, the target application is determined according to the detection instruction. Determining the Jar package directory corresponding to the target application specifically includes: identifying the application type of the target application; determining the scanning path of the target application based on the correspondence between the application type and the application path; and determining the Jar package directory under the scanning path as the Jar package directory corresponding to the target application. Scan each class in each Jar package in the Jar package directory. If there is a Jar package that depends on a class with the same name in the same path, then it is determined that there is a package conflict between the Jar packages that depend on the class with the same name in the same path. The detection of the called methods causing package conflicts in each group of Jar packages includes: reading a group of Jar packages to be detected that depend on classes with the same class name under the same path, and generating class files corresponding to each Jar package; decompiling the class files corresponding to each Jar package into Java files; based on the Java files corresponding to each Jar package, obtaining all called methods in each Jar package and generating a method set corresponding to each Jar package; taking the intersection of each Jar package to obtain the intersection result; taking the difference between each Jar package and the intersection result to obtain the code corresponding to the called methods with differences in each Jar package and saving it. Obtain the incremental code of the target application and determine whether the incremental code contains a called method that causes a package conflict; If the incremental code contains a called method that causes a package conflict, a conflict alert is generated.

2. The Jar packet conflict detection method according to claim 1, characterized in that, The method invoked in each group of Jar packages that detects packet conflicts, and which triggers the packet conflict, includes: The detection order is obtained by sorting the groups of Jar packets with packet conflicts according to the preset priority. According to the detection order, the called methods that caused the package conflict in each group of Jar packages with package conflicts are detected sequentially.

3. The Jar packet conflict detection method according to claim 1, characterized in that, The method further includes: The personnel who receive the alerts will be identified based on the target application. The conflict alert is sent to the alerting personnel.

4. A Jar packet conflict detection device, characterized in that, include: The first determining module is used to determine the target application when the triggering conditions are met, specifically including: determining the application as the target application when it is recognized that the application has been successfully deployed and the application status is available; or determining the target application according to the detection instruction when a detection instruction is received; The second determining module is used to determine the Jar package directory corresponding to the target application, specifically including: identifying the application type of the target application; determining the scanning path of the target application according to the correspondence between the application type and the application path; and determining the Jar package directory under the scanning path as the Jar package directory corresponding to the target application. The scanning module is used to scan each class in each Jar package in the Jar package directory. If there is a Jar package that depends on a class with the same name in the same path, it is determined that there is a package conflict between the Jar packages that depend on the class with the same name in the same path. The detection module is used to detect the called methods that cause package conflicts in each group of Jar packages. Specifically, it includes: reading a group of Jar packages to be detected that depend on classes with the same class name under the same path, and generating class files corresponding to each Jar package; decompiling the class files corresponding to each Jar package into Java files; based on the Java files corresponding to each Jar package, obtaining all called methods in each Jar package and generating a method set corresponding to each Jar package; taking the intersection of each Jar package to obtain the intersection result; taking the difference between each Jar package and the intersection result to obtain the code corresponding to the called methods that differ in each Jar package and saving it. The code judgment module is used to obtain the incremental code of the target application and determine whether the incremental code contains a called method that causes a package conflict. An alarm generation module is used to generate a conflict alarm when the incremental code contains a called method that causes a package conflict.

5. A storage medium, characterized in that: The storage medium stores computer-readable instructions that, when executed by one or more processors, cause the one or more processors to perform the steps of the Jar packet conflict detection method as described in any one of claims 1 to 3.

6. A computer device, characterized in that, include: One or more processors, and memory; The memory stores computer-readable instructions, and when the one or more processors execute the computer-readable instructions, they perform the steps of the Jar packet conflict detection method as described in any one of claims 1 to 3.

Citation Information

Patent Citations

  • Dependence package version management method and system

    CN108334334A

  • Automatic detection method for Java software project dependency conflict semantic consistency

    CN112181858A