Java project installation package deployment method, device, terminal equipment and readable medium
By building Jar package pool and generating Rom packages, the problem of excessive installation packages in Java projects is solved, and the installation package size is effectively reduced and loading efficiency is improved.
Patent Information
- Application Number
- CN202210065108.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-20
- Publication Date
- 2025-05-06
- Estimated Expiration
- 2042-01-20
AI Technical Summary
Traditional Java projects cannot effectively reduce the size of the installation package through Maven packaging, resulting in too large installation packages, affecting deployment efficiency and version maintenance costs.
By obtaining the external dependency Jar package, the external dependency Jar package manifest and the main module's service image from the compressed package uploaded in the service packaging stage, building the Jar package pool and packaging them together to generate the Rom package, thereby realizing the deployment of the Java project installation package.
By deduplication processing of external dependent Jar packages, the installation package size occupied by Java projects is effectively reduced and the efficiency of loading Java projects is improved.
Smart Images

Figure CN114489699B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of installation package deployment, and in particular to a Java project installation package deployment method, device, terminal equipment and readable medium. Background Art
[0002] In the scenario of enterprise private deployment, the entire system needs to be delivered in the form of an installation package. When there are multiple Java projects in the system, the Java projects can be specially processed through packaging and deployment, thereby reducing the size of the installation package occupied by the Java project. However, traditional Java projects are usually packaged into a Jar package through Maven. This method cannot reduce the memory of the Java project installation package. If the installation package is too large, it will not only affect the efficiency of technical support engineers to deploy the system to customers due to the long transmission time, but also lead to excessively high costs for maintenance of the installation package version. Therefore, a new installation package packaging and deployment method is urgently needed to solve the problem of too large Java project installation packages when enterprises deploy private systems. Summary of the invention
[0003] The purpose of the present invention is to provide a Java project installation package deployment method, device, terminal device and readable medium to solve the problem that the existing Java project packaging method cannot effectively reduce the size of the installation package.
[0004] To achieve the above object, the present invention provides a Java project installation package deployment method, comprising:
[0005] Obtain the external dependency Jar package, the external dependency Jar package list, and the service image of the main module from the compressed package uploaded during the service packaging phase; and use the external dependency Jar package to build a Jar package pool;
[0006] Package the external dependency Jar package list, the service image and the Jar package pool together to generate a Rom package;
[0007] According to the Rom package, the deployment operation of the Java project installation package is performed.
[0008] Further, as a preferred method, before obtaining the external dependency Jar package, the external dependency Jar package list and the service image of the main module from the compressed package uploaded in the service packaging stage, it also includes:
[0009] Separately package the main module Jar package and external dependency Jar package of the Java project;
[0010] Compress the service image, external dependency Jar package and external dependency Jar package list after packaging the main module Jar package to generate a compressed package.
[0011] Further, as a preferred embodiment, the deployment operation of the Java project installation package according to the Rom package includes:
[0012] According to the Rom package, restore the service image; and according to the external dependency Jar package list, restore the external dependency Jar package from the Jar package pool;
[0013] Mount the restored external dependency Jar package to the corresponding service image;
[0014] Start a Java project.
[0015] Further, preferably, the service image is a Docker image.
[0016] The present invention also provides a Java project installation package deployment device, comprising:
[0017] A Jar package pool building module is used to obtain the external dependency Jar package, the external dependency Jar package list and the service image of the main module from the compressed package uploaded in the service packaging phase; and to build a Jar package pool using the external dependency Jar package;
[0018] A Rom package generation module, used to package the external dependency Jar package list, the service image and the Jar package pool together to generate a Rom package;
[0019] The installation package deployment module is used to deploy the Java project installation package according to the Rom package.
[0020] Further, as a preferred embodiment, the Java project installation package deployment device further includes:
[0021] The service packaging module is used to package the main module Jar package and external dependency Jar package of the Java project separately;
[0022] The compression module is used to compress the service image, external dependency Jar package and external dependency Jar package list after the main module Jar package is packaged to generate a compressed package.
[0023] Further, as a preferred embodiment, the installation package deployment module is also used to:
[0024] According to the Rom package, restore the service image; and according to the external dependency Jar package list, restore the external dependency Jar package from the Jar package pool;
[0025] Mount the restored external dependency Jar package to the corresponding service image;
[0026] Start a Java project.
[0027] Further, preferably, the service image is a Docker image.
[0028] The present invention also provides a terminal device, comprising:
[0029] one or more processors;
[0030] A memory, coupled to the processor, for storing one or more programs;
[0031] When the one or more programs are executed by the one or more processors, the one or more processors implement the Java project installation package deployment method as described in any one of the above items.
[0032] The present invention also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the Java project installation package deployment method as described in any one of the above items is implemented.
[0033] Compared with the prior art, the beneficial effects of the present invention are:
[0034] The present invention discloses a Java project installation package deployment method, device, terminal equipment and readable medium. The method comprises: obtaining an external dependency Jar package, an external dependency Jar package list and a service image of a main module from a compressed package uploaded in a service packaging phase; building a Jar package pool using the external dependency Jar package; packaging the external dependency Jar package list, the service image and the Jar package pool together to generate a Rom package; and performing a Java project installation package deployment operation according to the Rom package.
[0035] The Java project installation package deployment method provided by the present invention can effectively reduce the size of the installation package occupied by the Java project by deduplicating repeated external dependency Jar packages in the packaging stage of the installation package, and restore the external dependency Jar packages of the Java project by restoring them in the deployment stage. The present invention effectively reduces the size of the installation package before the Java project is started, thereby greatly improving the efficiency of loading the Java project. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] In order to more clearly illustrate the technical solution of the present invention, the drawings required for use in the implementation mode will be briefly introduced below. Obviously, the drawings described below are only some implementation modes of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0037] Figure 1 It is a flowchart of a Java project installation package deployment method provided by an embodiment of the present invention;
[0038] Figure 2 It is a flowchart of a Java project installation package deployment method provided by another embodiment of the present invention;
[0039] Figure 3 yes Figure 1 Schematic diagram of the process of the sub-steps of step S30;
[0040] Figure 4 It is a flowchart of a Java project installation package deployment method provided by another embodiment of the present invention;
[0041] Figure 5 It is a structural diagram of a Java project installation package deployment device provided by an embodiment of the present invention;
[0042] Figure 6 It is a structural diagram of a Java project installation package deployment device provided by another embodiment of the present invention;
[0043] Figure 7 It is a schematic diagram of the structure of a terminal device provided by a certain embodiment of the present invention. DETAILED DESCRIPTION
[0044] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0045] It should be understood that the step numbers used in this document are only for convenience of description and are not intended to limit the order in which the steps are executed.
[0046] It should be understood that the terms used in the present specification are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the present specification and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.
[0047] The terms “include” and “comprising” indicate the presence of described features, integers, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.
[0048] The term "and / or" means and includes any and all possible combinations of one or more of the associated listed items.
[0049] First, the terms involved in the embodiments of the present invention are explained:
[0050] Maven: It is a tool provided for Java project dependency management. The dependencies that the project needs to introduce must be configured in the Maven configuration file.
[0051] Jar package: refers to the product generated by packaging and compressing some Java classes. Java projects can introduce required third-party Jar packages through Maven configuration, and Java projects can be packaged into Jar packages that can be run directly through Maven.
[0052] External dependency Jar package: refers to other Jar packages that the project needs to depend on, except for the main module Jar package where the Java startup class is located. They are collectively called external dependency Jar packages.
[0053] Rom package: system installation package
[0054] Nexus: refers to a Maven repository manager used to maintain internal repositories and access external repositories.
[0055] See also Figure 1 , a certain embodiment of the present invention provides a Java project installation package deployment method. Figure 1 As shown, the Java project installation package deployment method includes steps S10 to S30. The specific steps are as follows:
[0056] S10, obtaining the external dependency Jar package, the external dependency Jar package list and the service image of the main module from the compressed package uploaded in the service packaging stage; and constructing a Jar package pool using the external dependency Jar package;
[0057] S20, packaging the external dependency Jar package list, the service image and the Jar package pool together to generate a Rom package;
[0058] S30. Perform a deployment operation of the Java project installation package according to the Rom package.
[0059] It should be noted that in the existing scenario of enterprise privatization deployment. For the processing method of Java project-like system installation packages, Maven is usually used to package the entire project into a Jar package. The packaged service image directly includes the main module Jar package and the external dependency Jar package. Therefore, the redundant Jar packages in each service image cannot be deduplicated. Therefore, this embodiment aims to deduplicate the external dependency Jar packages of each project through a new packaging method to reduce the size of the Rom package.
[0060] Specifically, in this embodiment, steps S10 and S20 are mainly in the Rom package packaging stage, and their purpose is to perform deduplication operations on external dependent Jar packages; step S30 is mainly the deployment stage, in order to restore all compressed packages for deployment work before starting the installation package.
[0061] In a specific embodiment, before executing step S10, steps S08 and S09 are also executed. Figure 2 The specific contents of steps S08 and S09 are as follows:
[0062] S08. Separately package the main module Jar package and external dependency Jar package of the Java project;
[0063] S09. Compress the service image, external dependency Jar package and external dependency Jar package list after the main module Jar package is packaged together to generate a compressed package.
[0064] It should be noted that steps S08 and S09 are mainly operations in the service packaging stage. In this embodiment, the separate packaging of the main module Jar package and the external dependency Jar package is mainly achieved by changing the packaging result of the Java project. Specifically, it is mainly achieved by modifying the Maven packaging configuration of the Java project. Then. During the execution of the CI script in the service packaging stage, the external dependency package list corresponding to the Java project is generated by retrieving the external dependency Jar package of the project. Finally, the service image obtained by packaging the main module Jar package is uploaded, and the external dependency Jar package and the external dependency package list are compressed and uploaded together.
[0065] Further, execute steps S10 and S20, that is, enter the Rom package packaging stage. In this stage, first pull the service image of each service, the external dependency Jar package list and the external dependency Jar package. Then generate a Jar package pool based on the external dependency Jar package. It should be noted that since the technology stack of the Java project is the same, there are many common external dependencies between the modules. In the process of pulling the external dependency Jar package of the service, the packaging script pulls these files into the same directory. This directory plays the role of deduplication and space reduction of the Jar package, so it is called a "Jar package pool". It is precisely because the main module Jar package and the external dependency Jar package are separated in the service packaging stage, so in the Rom package packaging stage, the external dependency Jar package of each project can be deduplicated separately, thereby truly reducing the size of the Rom package.
[0066] Finally, after the Rom package packaging phase is completed, step S30 is executed, that is, entering the deployment phase. Figure 3 Schematic diagram of the flow of sub-steps of step S30. Specifically, the sub-steps of step S30 include the following contents:
[0067] S301, restore the service image according to the Rom package; and restore the external dependent Jar package from the Jar package pool according to the external dependent Jar package list;
[0068] S302, mount the restored external dependency Jar package to the corresponding service image;
[0069] S303. Start the Java project.
[0070] It should be noted that in this embodiment, the image of each service is pulled from the Rom package generated in the previous step; and the external dependency Jar package list of each service, and then all external dependency Jar packages of the service can be restored from the Jar package pool according to the external dependency Jar package list, and finally, the external dependency Jar packages of each service only need to be mounted to their corresponding service images, and all Java projects can be successfully started. Among them, the service image described in the above embodiment mainly refers to the Docker image.
[0071] In one embodiment, a flow chart of these three stages is provided, such as Figure 4 As shown. Among them, the Java project installation package deployment method mainly includes a service packaging stage, a Rom package packaging stage and a deployment stage. Among them, the Java project can be one or more. In the service packaging stage, by packaging the Jar package of the main module and the external dependency Jar package separately, the packaged Docker service image of the main module and the compressed external dependency Jar package can be obtained respectively. Then, by retrieving the external dependency Jar package of the project, the external dependency package list of the Java project can be generated, and the Docker service image, the packaged external dependency Jar package and the external dependency package list are uploaded to Nexus together, so that it enters the Rom package packaging stage. Further, in the Rom package packaging stage, the external dependency Jar package can be pulled separately, and these files are pulled into the same directory through the packaging script to generate a Jar package pool, so as to play the role of Jar package deduplication and space reduction. Then the Jar package pool, Docker service image and external dependency package list are packaged together to generate a Rom package, and enter the deployment stage. Finally, in the deployment stage, for each Java project. Pull each Docker service image separately and restore the external dependency package from the Jar package pool according to the external dependency package list. Then you only need to mount the external dependency package to the most corresponding Docker service image to successfully start the Java project.
[0072] In summary, the Java project installation package deployment method provided by the embodiment of the present invention can effectively reduce the size of the installation package occupied by the Java project by deduplicating the repeated external dependency Jar packages in the packaging stage of the installation package, and restore the external dependency Jar packages of the Java project by restoring them in the deployment stage. This embodiment effectively reduces the size of the installation package before the Java project is started, thereby greatly improving the efficiency of loading the Java project.
[0073] See also Figure 5 , an embodiment of the present invention further provides a Java project installation package deployment device, comprising:
[0074] The Jar package pool construction module 10 is used to obtain the external dependency Jar package, the external dependency Jar package list and the service image of the main module from the compressed package uploaded in the service packaging stage; and to construct the Jar package pool using the external dependency Jar package;
[0075] A Rom package generation module 20 is used to package the external dependency Jar package list, the service image and the Jar package pool together to generate a Rom package;
[0076] The installation package deployment module 30 is used to perform the deployment operation of the Java project installation package according to the Rom package.
[0077] See also Figure 6 In a specific embodiment of the present invention, the Java project installation package deployment device further includes:
[0078] Service packaging module 08, used to package the main module Jar package and external dependency Jar package of the Java project separately;
[0079] The compression module 09 is used to compress the service image, external dependency Jar package and external dependency Jar package list after the main module Jar package is packaged to generate a compressed package.
[0080] In a specific embodiment, the installation package deployment module 30 is further used to:
[0081] According to the Rom package, restore the service image; and according to the external dependency Jar package list, restore the external dependency Jar package from the Jar package pool;
[0082] Mount the restored external dependency Jar package to the corresponding service image;
[0083] Start a Java project.
[0084] In a specific embodiment, the service image is a Docker image.
[0085] It is understandable that the Java project installation package deployment device provided in the embodiment of the present invention is used to execute the Java project installation package deployment method as described in any of the above embodiments. This embodiment can effectively reduce the size of the installation package occupied by the Java project by deduplicating the repeated external dependency Jar packages during the packaging phase of the installation package, and restore the external dependency Jar packages of the Java project through restoration processing during the deployment phase. This embodiment effectively reduces the size of the installation package before the Java project is started, thereby greatly improving the efficiency of loading the Java project.
[0086] See also Figure 7 , a certain embodiment of the present invention provides a terminal device, including:
[0087] one or more processors;
[0088] A memory, coupled to the processor, for storing one or more programs;
[0089] When the one or more programs are executed by the one or more processors, the one or more processors implement the Java project installation package deployment method as described above.
[0090] The processor is used to control the overall operation of the terminal device to complete all or part of the steps of the above-mentioned Java project installation package deployment method. The memory is used to store various types of data to support the operation of the terminal device, and these data may include, for example, instructions for any application or method used to operate on the terminal device, and application-related data. The memory can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (Static Random Access Memory, referred to as SRAM), electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, referred to as EEPROM), erasable programmable read-only memory (Erasable Programmable Read-Only Memory, referred to as EPROM), programmable read-only memory (Programmable Read-Only Memory, referred to as PROM), read-only memory (Read-Only Memory, referred to as ROM), magnetic memory, flash memory, disk or optical disk.
[0091] In an exemplary embodiment, the terminal device can be implemented by one or more application specific integrated circuits (Application Specific Integrated Circuit, ASC), digital signal processors (Digital Signal Processor, DSP), digital signal processing devices (Digital Signal Processing Device, DSPD), programmable logic devices (Programmable Logic Device, PLD), field programmable gate arrays (Field Programmable Gate Array, FPGA), controllers, microcontrollers, microprocessors or other electronic components, and is used to execute the Java project installation package deployment method described in any of the above embodiments, and achieve the same technical effect as the above method.
[0092] In another exemplary embodiment, a computer-readable medium including a computer program is also provided, and when the computer program is executed by a processor, the steps of the Java project installation package deployment method described in any of the above embodiments are implemented. Among them, the computer-readable medium of the embodiment of the present application can be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. More specific examples of computer-readable storage media include at least (non-exhaustive list) the following: an electrical connection portion (electronic device) with one or more wirings, a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and editable read-only memory (EPROM or flash memory), an optical fiber device, and a portable read-only memory (CDROM). In addition, the computer-readable storage medium can even be paper or other suitable media on which the program can be printed, because the program can be obtained electronically, for example, by optically scanning the paper or other media, followed by editing, interpreting or processing in other suitable ways as necessary, and then stored in a computer memory.
[0093] In an embodiment of the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, wherein a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by an instruction execution system, an input method, or a device or used in combination with the program. The program code contained on the computer-readable medium may be transmitted using any suitable medium, including but not limited to: wireless, wire, optical cable, radio frequency (RF), etc., or any suitable combination of the above.
[0094] The above is a preferred embodiment of the present invention. It should be pointed out that a person skilled in the art can make several improvements and modifications without departing from the principle of the present invention. These improvements and modifications are also considered to be within the scope of protection of the present invention.
Claims
1. A Java project installation package deployment method, characterized in that: include: Obtain the external dependency Jar package, external dependency Jar package list, and service image of the main module from the compressed package uploaded during the service packaging phase; Using the external dependency Jar package to build a Jar package pool; Package the external dependency Jar package list, the service image and the Jar package pool together to generate a Rom package; According to the Rom package, the Java project installation package is deployed; The step of building a Jar package pool by using the external dependent Jar package includes: When pulling the external dependency Jar package of the service, the packaging script pulls the common external dependency files into the same directory; The directory is used to remove duplicate Jar packages.
2. The Java project installation package deployment method according to claim 1, characterized in that: Before obtaining the external dependency Jar package, the external dependency Jar package list and the service image of the main module from the compressed package uploaded in the service packaging stage, it also includes: Separately package the main module Jar package and external dependency Jar package of the Java project; Compress the service image, external dependency Jar package and external dependency Jar package list after packaging the main module Jar package to generate a compressed package.
3. The Java project installation package deployment method according to claim 1, characterized in that: The step of performing a deployment operation of a Java project installation package according to the Rom package includes: According to the Rom package, restore the service image; and according to the external dependency Jar package list, restore the external dependency Jar package from the Jar package pool; Mount the restored external dependency Jar package to the corresponding service image; Start a Java project.
4. The Java project installation package deployment method according to any one of claims 1 to 3, characterized in that: The service image is a Docker image.
5. A Java project installation package deployment device, characterized in that: include: A Jar package pool building module is used to obtain the external dependency Jar package, the external dependency Jar package list and the service image of the main module from the compressed package uploaded in the service packaging phase; and to build a Jar package pool using the external dependency Jar package; A Rom package generation module, used to package the external dependency Jar package list, the service image and the Jar package pool together to generate a Rom package; An installation package deployment module, used to perform a deployment operation of a Java project installation package according to the Rom package; The step of building a Jar package pool by using the external dependent Jar package includes: When pulling the external dependency Jar package of the service, the packaging script pulls the common external dependency files into the same directory; The directory is used to remove duplicate Jar packages.
6. The Java project installation package deployment device according to claim 5, characterized in that: Also includes: The service packaging module is used to package the main module Jar package and external dependency Jar package of the Java project separately; The compression module is used to compress the service image, external dependency Jar package and external dependency Jar package list after the main module Jar package is packaged to generate a compressed package.
7. The Java project installation package deployment device according to claim 5, characterized in that: The installation package deployment module is also used to: According to the Rom package, restore the service image; and according to the external dependency Jar package list, restore the external dependency Jar package from the Jar package pool; Mount the restored external dependency Jar package to the corresponding service image; Start a Java project.
8. The Java project installation package deployment device according to any one of claims 5 to 7, characterized in that: The service image is a Docker image.
9. A terminal device, characterized in that: include: one or more processors; A memory, coupled to the processor, for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the Java project installation package deployment method as described in any one of claims 1 to 4.
10. A computer readable medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the Java project installation package deployment method according to any one of claims 1 to 4 is implemented.
Citation Information
Patent Citations
A micro-service packaging deployment method and system
CN109634657A