Java project deployment method and device, electronic equipment and storage medium
By determining the deployment information and environment variables of Java projects, and utilizing CI tools and rule engines, automated deployment of Java projects is achieved, solving the problem of long deployment times and improving deployment efficiency.
Patent Information
- Application Number
- CN202511733457.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-24
- Publication Date
- 2026-02-17
AI Technical Summary
Existing Java project deployment methods are time-consuming, impacting programmers' work efficiency.
By determining the deployment information and environment variables of the target Java project, including its microservice, Git repository address, branch name, source code directory, build path, JAR path, mapped port, and context path, automated deployment can be achieved using CI tools and a rule engine.
It enables rapid deployment of Java projects, improves deployment efficiency, and reduces manual intervention time.
Smart Images

Figure CN121541894A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of project deployment technology, and in particular to a Java project deployment method, apparatus, electronic device, and storage medium. Background Technology
[0002] A Java project is a collection of software developed using the Java programming language to implement specific business functions or solve specific problems.
[0003] Existing Java projects are often deployed manually, but manual deployment is time-consuming and affects the work efficiency of programmers. Therefore, there is an urgent need for a method that can quickly complete project deployment. Summary of the Invention
[0004] This invention provides a Java project deployment method, apparatus, electronic device, and storage medium to solve the problem of slow Java project deployment.
[0005] According to one aspect of the present invention, a Java project deployment method is provided, the method comprising:
[0006] Determine the deployment information of the target Java project. The deployment information of the Java project includes the microservice it belongs to, the Git repository address, the branch name, the source code directory, the build path, the Jar path, the mapped port, and the context path.
[0007] Determine the environment variable information of the target Java project;
[0008] The target Java project is deployed based on deployment information and environment variable information.
[0009] According to another aspect of the present invention, a Java project deployment apparatus is provided, the apparatus comprising:
[0010] The deployment information determination module is used to determine the deployment information of the target Java project. The deployment information of the Java project includes the microservice it belongs to, the Git repository address, the branch name, the source code directory, the build path, the Jar path, the mapped port, and the context path.
[0011] The environment variable determination module is used to determine the environment variable information of the target Java project;
[0012] The project deployment module is used to deploy the target Java project based on deployment information and environment variable information.
[0013] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:
[0014] At least one processor; and
[0015] A memory that is communicatively connected to at least one processor; wherein,
[0016] The memory stores a computer program that can be executed by at least one processor, such that the at least one processor is able to execute the Java project deployment method of any embodiment of the present invention.
[0017] According to another aspect of the present invention, a computer-readable storage medium is provided, which stores computer instructions for causing a processor to execute and implement the Java project deployment method of any embodiment of the present invention.
[0018] The technical solution of this invention determines the deployment information of the target Java project, including the microservice it belongs to, the Git repository address, the branch name, the source code directory, the build path, the Jar path, the mapped port, and the context path. It also determines the environment variable information of the target Java project. Based on the deployment information and the environment variable information, the target Java project is deployed, which enables the rapid deployment of Java projects.
[0019] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description
[0020] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0021] Figure 1 This is a flowchart of a Java project deployment method provided in Embodiment 1 of the present invention;
[0022] Figure 2 This is a flowchart of another Java project deployment method provided in Embodiment 2 of the present invention;
[0023] Figure 3 This is a schematic diagram of the structure of a Java project deployment device according to Embodiment 3 of the present invention;
[0024] Figure 4 This is a schematic diagram of the structure of an electronic device that implements the Java project deployment method of this invention. Detailed Implementation
[0025] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0026] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0027] Example 1
[0028] Figure 1 This is a flowchart illustrating a Java project deployment method according to Embodiment 1 of the present invention. This embodiment is applicable to situations involving Java projects. The method can be executed by a Java project deployment device, which can be implemented in hardware and / or software and can be configured in an electronic device with data processing capabilities. Figure 1 As shown, the method includes:
[0029] S110. Determine the deployment information of the target Java project. The deployment information of the Java project includes the microservice it belongs to, the Git repository address, the branch name, the source code directory, the build path, the Jar path, the mapped port, and the context path.
[0030] A Java project is a collection of software developed using the Java programming language to implement specific business functions or solve specific problems. A microservice can be part of a microservice architecture, where a large system is broken down into multiple independently running smaller services, each responsible for a specific business function. A Git repository address is the storage location of the project's source code in the Git version control system, used for code submission, pulling, and branch management during team collaboration. A branch name is a code branch in the Git repository used to distinguish different development stages or functions. The source code directory is the directory path where the project stores Java source code (.java files), configuration files (.properties, .xml, etc.). The build path is the resource path configuration that the project depends on during compilation, including the source code directory, dependent libraries (JAR packages), output directories, etc. The JAR path is the storage path of the JAR file (Java archive file, containing compiled class files and resources) generated after the project is compiled and packaged. The mapped port is the server port bound to during project runtime, used for external access to the service over the network. The context path is the base path (prefix) when accessing a web application, used to distinguish multiple web applications on the same server.
[0031] S120. Determine the environment variable information of the target Java project.
[0032] Environment variables are dynamically configured values that can be accessed during project runtime. They store parameters related to the runtime environment, such as database addresses, keys, and ports. This avoids hardcoding sensitive information into the code and facilitates switching configurations across different environments (development, testing, and production). Environment variables decouple configuration from code, enable multi-environment adaptation, and allow for flexible project deployment.
[0033] S130. Deploy the target Java project based on deployment information and environment variable information.
[0034] When deploying a Java project, key information must be clearly defined, including the microservice it belongs to, the Git repository address, branch name, source code directory, build path, JAR path, mapped port, and context path. Furthermore, to address the issue of the same code running with different configurations in different environments, environment variables should be defined and categorized by environment to avoid hardcoding. Environment variables can include development environment (dev), testing environment (test), pre-release environment (staging), and production environment (prod). Specifically: Development environment (dev): Configured on the developer's local machine or development server, including the local database and test keys. Testing environment (test): Used for QA testing, configuring the test database and test interface address. Pre-release environment (staging): Simulates production configuration, with data consistent with production (data anonymized), used for pre-deployment verification. Production environment (prod): The production runtime environment, configured with the production database, encryption keys, and high-availability service address.
[0035] Based on the project's Git repository address and branch name, pull the source code using CI tools (such as Jenkins or GitLab CI); based on the source code directory and build path, build an executable JAR package using Maven / Gradle; ensure that JDK is installed on the target server and check for port conflicts, injecting environment variables according to the target environment; upload the package corresponding to the "JAR path" to the deployment directory of the target server; start the container using the container command, and the container will automatically run the JAR package; check if the "mapped port" is listening correctly; access the service health check interface through the "context path"; view the output under the log path; use tools such as Jenkins, GitLab CI, and GitHub Actions to write the "pull code → build → deploy" process into a pipeline script to achieve one-click deployment.
[0036] Optionally, based on deployment information and environment variable information, the target Java project is deployed, including:
[0037] Determine the gittoken information corresponding to the git repository address;
[0038] The gittoken information and deployment information are sent to a pre-built rules engine, which then deploys the target Java project.
[0039] A rule engine can be a script or other program that can automate operations.
[0040] First, determine the git token information corresponding to the git repository address. Then, send the git token information and deployment information to the pre-built rule engine. The rule engine will automatically execute the project deployment to achieve the deployment of the target Java project.
[0041] By adopting the technical solution of this application, the deployment information of the target Java project is determined, including the microservice to which it belongs, the Git repository address, the branch name, the source code directory, the build path, the Jar path, the mapped port, and the context path. The environment variable information of the target Java project is also determined. Based on the deployment information and the environment variable information, the target Java project is deployed, which enables the rapid deployment of Java projects.
[0042] Example 2
[0043] Figure 2 This invention provides a flowchart of another Java project deployment method. This embodiment further optimizes the process after deploying the target Java project based on deployment information and environment variable information, building upon the previous embodiments. This embodiment can be combined with various optional solutions from one or more of the above embodiments. Figure 2 As shown, the Java project deployment method in this embodiment may include the following steps:
[0044] S210. Determine the deployment information of the target Java project. The deployment information of the Java project includes the microservice it belongs to, the Git repository address, the branch name, the source code directory, the build path, the Jar path, the mapped port, and the context path.
[0045] S220. Determine the environment variable information of the target Java project.
[0046] S230. Deploy the target Java project based on deployment information and environment variable information.
[0047] S240. If the target Java project fails to deploy, redeploy the target Java project.
[0048] Considering that Java project deployment may encounter anomalies that could lead to deployment failure, the target Java project will be redeployed if deployment fails.
[0049] Optionally, if the target Java project fails to deploy, redeploy the target Java project, including:
[0050] Perform periodic checks to ensure the target Java project has been successfully deployed. If the target Java project has not been successfully deployed, redeploy it.
[0051] To determine whether the target Java project has been successfully deployed, you can periodically check whether the target Java project has been successfully deployed.
[0052] Optionally, periodically check whether the target Java project has been successfully deployed. If the target Java project has not been successfully deployed, redeploy it, including:
[0053] The system checks whether the target Java project has been successfully deployed and obtains the results. The results include whether the build failed, the build succeeded, or the build is in progress.
[0054] If the test result indicates a build failure, redeploy the target Java project.
[0055] If the detection result is "building", then after a preset time period, the target Java project will be re-detected to see if it has been successfully deployed.
[0056] If the detection result indicates successful construction, then the deployment of the target Java project will be stopped, and the detection of whether the target Java project has been successfully deployed will also be stopped.
[0057] Considering that there are various scenarios during the construction of the target Java project, including build failure, build success, and build in progress, different operations can be performed depending on the specific scenario.
[0058] If the detection result is a build failure, the target Java project will be redeployed; if the detection result is a build in progress, the target Java project will be re-detected after a preset time period to see if the deployment was successful; if the detection result is a build success, the deployment of the target Java project will be stopped, and the detection of whether the target Java project was successfully deployed will also be stopped.
[0059] Optionally, checks can be performed to determine whether the target Java project has been successfully deployed, including:
[0060] The Swagger-UI tool is used to check whether the target Java project has been successfully deployed.
[0061] Swagger-UI is a visual API documentation tool that can automatically generate interactive documentation for backend API interfaces, supporting online viewing of interface information and debugging of interfaces.
[0062] If the Swagger-UI documentation page can be accessed normally and the API can be parsed, the project deployment is basically successful; otherwise, there is a deployment problem.
[0063] By adopting the technical solution of this application, if the target Java project fails to deploy, it can be redeployed, thus avoiding the problem of the target Java project failing to deploy and ultimately affecting the project progress.
[0064] Example 3
[0065] Figure 3 This invention provides a structural block diagram of a Java project deployment device, applicable to scenarios involving Java projects. This Java project deployment device can be implemented in hardware and / or software and can be configured in an electronic device with data processing capabilities. Figure 3 As shown, the Java project deployment device of this embodiment may include: a deployment information determination module 310, an environment variable determination module 320, and a project deployment module 330. Wherein:
[0066] The deployment information determination module 310 is used to determine the deployment information of the target Java project. The deployment information of the Java project includes the microservice to which it belongs, the Git repository address, the branch name, the source code directory, the build path, the Jar path, the mapped port, and the context path.
[0067] The environment variable determination module 320 is used to determine the environment variable information of the target Java project.
[0068] Project deployment module 330 is used to deploy the target Java project based on deployment information and environment variable information.
[0069] Based on the above embodiments, optionally, the project deployment module 330 includes:
[0070] Determine the gittoken information corresponding to the git repository address;
[0071] The gittoken information and deployment information are sent to a pre-built rules engine, which then deploys the target Java project.
[0072] Optionally, based on the above embodiments, after the project deployment module 330, the following may also be included:
[0073] If the target Java project fails to deploy, redeploy the target Java project.
[0074] Based on the above embodiments, optionally, if the target Java project fails to deploy, the target Java project is redeployed, including:
[0075] Perform periodic checks to ensure the target Java project has been successfully deployed. If the target Java project has not been successfully deployed, redeploy it.
[0076] Based on the above embodiments, optionally, the successful deployment of the target Java project can be periodically checked. If the target Java project fails to deploy, it can be redeployed, including:
[0077] The system checks whether the target Java project has been successfully deployed and obtains the results. The results include whether the build failed, the build succeeded, or the build is in progress.
[0078] If the test result indicates a build failure, redeploy the target Java project.
[0079] If the detection result is "building", then after a preset time period, the target Java project will be re-detected to see if it has been successfully deployed.
[0080] If the detection result indicates successful construction, then the deployment of the target Java project will be stopped, and the detection of whether the target Java project has been successfully deployed will also be stopped.
[0081] Based on the above embodiments, optionally, the detection of whether the target Java project has been successfully deployed includes:
[0082] The Swagger-UI tool is used to check whether the target Java project has been successfully deployed.
[0083] The Java project deployment apparatus provided in this embodiment of the invention can execute the Java project deployment method provided in any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0084] Example 4
[0085] Figure 4 A schematic diagram of an electronic device 10, which can be used to implement embodiments of the present invention, is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.
[0086] like Figure 4As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12 or a random access memory (RAM) 13, communicatively connected to the at least one processor 11. The memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes based on the computer program stored in the ROM 12 or loaded from storage unit 18 into the RAM 13. The RAM 13 can also store various programs and data required for the operation of the electronic device 10. The processor 11, ROM 12, and RAM 13 are interconnected via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0087] Multiple components in electronic device 10 are connected to I / O interface 15, including: input unit 16, such as keyboard, mouse, etc.; output unit 17, such as various types of displays, speakers, etc.; storage unit 18, such as disk, optical disk, etc.; and communication unit 19, such as network card, modem, wireless transceiver, etc. Communication unit 19 allows electronic device 10 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0088] Processor 11 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Processor 11 performs the various methods and processes described above, such as Java project deployment methods.
[0089] In some embodiments, the Java project deployment method may be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or mounted on electronic device 10 via ROM 12 and / or communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the Java project deployment method described above may be performed. Alternatively, in other embodiments, processor 11 may be configured to execute the Java project deployment method by any other suitable means (e.g., by means of firmware).
[0090] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0091] Computer programs used to implement the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0092] In the context of this invention, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0093] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0094] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or middleware components (e.g., application servers), or frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.
[0095] A computing system can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a hosting product within the cloud computing service system to address the shortcomings of traditional physical hosts and VPS services, such as high management difficulty and weak business scalability.
[0096] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.
[0097] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.
Claims
1. A method for deploying a Java project, characterized in that, include: Determine the deployment information of the target Java project, which includes the microservice it belongs to, the Git repository address, the branch name, the source code directory, the build path, the Jar path, the mapped port, and the context path; Determine the environment variable information of the target Java project; Based on the deployment information and the environment variable information, the target Java project is deployed.
2. The method according to claim 1, characterized in that, Based on the deployment information and the environment variable information, the target Java project is deployed, including: Determine the gittoken information corresponding to the git repository address; The gittoken information and the deployment information are sent to a pre-built rules engine, which then deploys the target Java project.
3. The method according to claim 1, characterized in that, After deploying the target Java project based on the deployment information and the environment variable information, the process further includes: If the target Java project fails to deploy, then redeploy the target Java project.
4. The method according to claim 3, characterized in that, If the target Java project fails to deploy, redeploy the target Java project, including: The successful deployment of the target Java project is checked periodically. If the target Java project is not deployed successfully, it is redeployed.
5. The method according to claim 4, characterized in that, The successful deployment of the target Java project is periodically checked. If the target Java project fails to deploy, it is redeployed, including: The system checks whether the target Java project has been successfully deployed and obtains the results; the results include build failure, build success, and build in progress. If the detection result indicates a build failure, the target Java project will be redeployed. If the detection result is "under construction", then after a preset time period, the detection will be performed again to check whether the target Java project has been successfully deployed. If the detection result indicates successful construction, then the deployment of the target Java project is stopped, and the detection of whether the target Java project has been successfully deployed is also stopped.
6. The method according to claim 5, characterized in that, The detection of whether the target Java project has been successfully deployed includes: The Swagger-UI tool is used to check whether the target Java project has been successfully deployed.
7. A Java project deployment device, characterized in that, include: The deployment information determination module is used to determine the deployment information of the target Java project. The deployment information of the Java project includes the microservice to which it belongs, the Git repository address, the branch name, the source code directory, the build path, the Jar path, the mapped port, and the context path. An environment variable determination module is used to determine the environment variable information of the target Java project; The project deployment module is used to deploy the target Java project based on the deployment information and the environment variable information.
8. The apparatus according to claim 7, characterized in that, The project deployment module includes: The information acquisition module is used to determine the gittoken information corresponding to the git repository address; The deployment module is used to send the gittoken information and the deployment information to a pre-built rule engine, which then deploys the target Java project.
9. An electronic device, characterized in that, The electronic device includes: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the Java project deployment method according to any one of claims 1-6.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that cause a processor to execute the Java project deployment method according to any one of claims 1-6.