Application deployment method and device, equipment and storage medium
Filtering redundant JAR files by loading configuration tags through configuration classes, solving the problem of running exceptions caused by redundant files in WEB application deployment, and realizing the normal and stable operation of the application and simplified maintenance process.
Patent Information
- Application Number
- CN202411642741.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-18
- Publication Date
- 2025-02-11
AI Technical Summary
During the deployment of WEB application, redundant JAR files cause abnormal application operation, and the existing technology requires temporary annotation or deletion of redundant files, which increases the difficulty of application development and maintenance.
By loading the configuration tags through the configuration class, filter the redundant files in the file class library of the application to be deployed, only the actual target files are retained, and added to the class loader to achieve normal and stable operation of the application.
Without modifying the application layer files, the search and execution of redundant files are effectively avoided, the normal and stable operation of the application is ensured, and the subsequent operation and maintenance of the application server and WEB application are simplified.
Smart Images

Figure CN119415183A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of application deployment technology, and in particular to an application deployment method, device, equipment and storage medium. Background Art
[0002] During the deployment or access phase of a WEB (World Wide Web) application, the class loader searches for class files or resource files required for runtime from the file class library of the application to ensure the normal operation of the application. In some non-standard scenarios, there are some redundant JAR (Java Archive) files in the file class library of the WEB application, that is, the WEB application does not need these files during actual operation. However, due to the existence of redundant JAR files, the application identifies the class files or resource files in the redundant JAR files by calling the class file search method or the resource file search method during operation, resulting in the execution of the relevant program logic in these files, which in turn causes application operation exceptions, including but not limited to class loading conflict exceptions, application freeze exceptions, etc.
[0003] At present, when an application server searches for class files or resource files from a file library of a WEB application, in order to prevent finding class files or resource files in redundant JAR files, it is necessary to temporarily comment or delete the redundant JAR files, that is, only keep the files actually needed by the WEB application during operation. In this way, because the application layer files need to be modified, the development of WEB applications is relatively difficult, and it is inconvenient for the subsequent operation and maintenance of the application server and WEB applications.
[0004] In summary, how to ensure the normal and stable operation of WEB applications without modifying application layer files is a technical problem that needs to be solved urgently. Summary of the invention
[0005] In view of this, the purpose of the present invention is to provide an application deployment method, device, equipment and storage medium, which can ensure the normal and stable operation of WEB applications without modifying application layer files. The specific scheme is as follows:
[0006] In a first aspect, the present application provides an application deployment method, comprising:
[0007] Configure the attributes of the corresponding attribute configuration tag in the class loading configuration tag according to the file to be filtered; the class loading configuration tag is a configuration tag in the deployment description file of the application to be deployed, and the attributes include attribute name and attribute value;
[0008] Filter the corresponding to-be-filtered files in the file class library of the application to be deployed based on the attribute name in the class loading configuration tag to obtain the remaining target files in the file class library;
[0009] The target file in the file class library is added to the class loader corresponding to the application to be deployed, and the target file in the class loader is read, and the application to be deployed is deployed to the corresponding application server based on the read target file.
[0010] Optionally, the attributes of the attribute configuration tag corresponding to the attribute configuration tag in the configuration tag loaded according to the file to be filtered configuration class include:
[0011] Determining the file to be filtered in the file library of the application to be deployed;
[0012] According to the file to be filtered, the attribute name of the attribute configuration tag corresponding to the class loading configuration tag is configured to ignore loading, and the attribute value is configured to the file name of the file to be filtered.
[0013] Optionally, filtering the corresponding to-be-filtered files in the file class library of the to-be-deployed application based on the attribute name in the class loading configuration tag includes:
[0014] Utilizing the application server to parse the deployment description file of the application to be deployed to obtain the class loading configuration tag;
[0015] Determine the attribute value corresponding to the attribute configuration tag whose attribute name in the class loading configuration tag is to be ignored for loading;
[0016] Determine the file name of the corresponding file to be filtered according to the attribute value, store the file name of the file to be filtered in a preset ignored loading file array, and filter the corresponding file to be filtered in the file class library of the application to be deployed according to the preset ignored loading file array.
[0017] Optionally, filtering the corresponding to-be-filtered files in the file class library of the to-be-deployed application according to the preset ignored-loading file array includes:
[0018] Determine whether the file names of each file in the file class library of the application to be deployed are consistent with the file names of the to-be-filtered files in the preset ignored loading file array;
[0019] According to the judgment result, a file in the file class library of the application to be deployed whose file name is consistent with the file name of the file to be filtered in the preset ignored loading file array is used as the file to be filtered;
[0020] The to-be-filtered files in the file library of the to-be-deployed application are filtered to obtain remaining target files in the file library.
[0021] Optionally, adding the target file in the file class library to a class loader corresponding to the application to be deployed includes:
[0022] The class loader corresponding to the application to be deployed is created, and a preset file adding method in the class loader is called to add the target file in the file class library to the class path corresponding to the class loader.
[0023] Optionally, reading the target file in the class loader and deploying the to-be-deployed application to a corresponding application server based on the read target file includes:
[0024] Calling a preset file reading method in the class loader to read the target file, and deploying the application to be deployed based on the target file;
[0025] If the deployment of the application to be deployed fails, the first abnormal file in the target file is determined based on the deployment failure result, and the attribute name in the class loading configuration tag is modified to the attribute configuration tag that is ignored for loading according to the file name of the first abnormal file, so as to continue to deploy the application to be deployed to the corresponding application server according to the modified target attribute configuration tag.
[0026] Optionally, after reading the target file in the class loader and deploying the application to be deployed to a corresponding application server based on the read target file, the method further includes:
[0027] If the application to be deployed is successfully deployed, accessing the application to be deployed in the application server, and reading the target file in the class loader through the application to be deployed;
[0028] If access to the application to be deployed fails, the application to be deployed is uninstalled, and a second abnormal file in the target file is determined based on the access failure result, and the target attribute configuration tag is modified according to the file name of the second abnormal file, so that the application to be deployed is redeployed to the corresponding application server according to the modified target attribute configuration tag.
[0029] In a second aspect, the present application provides an application deployment device, including:
[0030] A tag configuration module, used to configure the attributes of the corresponding attribute configuration tag in the class loading configuration tag according to the file to be filtered; the class loading configuration tag is a configuration tag in the deployment description file of the application to be deployed, and the attributes include attribute name and attribute value;
[0031] A file filtering module, used to filter the corresponding to-be-filtered files in the file class library of the to-be-deployed application based on the attribute name in the class loading configuration tag, to obtain the remaining target files in the file class library;
[0032] The application deployment module is used to add the target file in the file library to the class loader corresponding to the application to be deployed, read the target file in the class loader, and deploy the application to be deployed to the corresponding application server based on the read target file.
[0033] In a third aspect, the present application provides an electronic device, including:
[0034] Memory, used to store computer programs;
[0035] The processor is used to execute the computer program to implement the aforementioned application deployment method.
[0036] In a fourth aspect, the present application provides a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, the aforementioned application deployment method is implemented.
[0037] In the present application, the attributes of the corresponding attribute configuration tag in the class loading configuration tag can be first configured according to the file to be filtered; wherein, the class loading configuration tag is a configuration tag in the deployment description file of the application to be deployed, and the attributes include attribute names and attribute values; then, based on the attribute names in the class loading configuration tag, the corresponding files to be filtered in the file class library of the application to be deployed are filtered to obtain the remaining target files in the file class library, and the target files in the file class library are added to the class loader corresponding to the application to be deployed to read the target files in the class loader, and the application to be deployed is deployed to the corresponding application server based on the target files. As can be seen from the above, before deploying the application, the present application first configures specific attributes for the file to be filtered, and then when deploying the application, based on the attributes of the file to be filtered, obtains the corresponding file to be filtered in the file library of the application to be deployed, and filters the file to be filtered from the file library of the application to be deployed. In this way, when the application to be deployed searches for class files or resource files from the file library, it no longer searches for the file to be filtered. That is, in the process of deploying the application, when searching for class files or resource files from the file library, it only searches for the remaining target files in the file library except the file to be filtered, and completes the operation of deploying the application to be deployed to the corresponding application server based on the target files. In this way, the present application can ignore the search for redundant files in the deployment stage or the access stage through the above process, thereby ensuring the normal and stable operation of the application. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0039] Figure 1 A flow chart of an application deployment method provided for this application;
[0040] Figure 2 A specific application deployment method flow chart provided for this application;
[0041] Figure 3 A deployment flow chart of a WEB application provided for this application;
[0042] Figure 4 A schematic diagram of the structure of an application deployment device provided for this application;
[0043] Figure 5 A structural diagram of an electronic device provided for this application. 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] At present, when an application server searches for class files or resource files from the file library of an application, in order to prevent finding class files or resource files in redundant files, it is necessary to temporarily annotate or delete the redundant files, that is, only retain the files actually needed by the application during operation. In this way, because the files at the application layer need to be modified, application development is relatively difficult, and it is inconvenient for the subsequent operation and maintenance of the application server and the application. To this end, the present application provides an application deployment solution that can ensure the normal and stable operation of WEB applications without modifying the application layer files.
[0046] See also Figure 1 As shown, an embodiment of the present invention discloses an application deployment method, which may include:
[0047] Step S11, configuring the attributes of the corresponding attribute configuration tag in the class loading configuration tag according to the file to be filtered; the class loading configuration tag is a configuration tag in the deployment description file of the application to be deployed, and the attributes include attribute name and attribute value.
[0048] In this embodiment, the application to be deployed can be a WEB application, which is usually a B / S mode (B / S, i.e., Browser / Server), and the WEB application can be accessed through a browser. In order to configure the attribute configuration tags corresponding to the file to be filtered, it is first necessary to define inforsuite-web.xml, i.e., the deployment description file of the application to be deployed. The deployment description file is located in the standard folder under the WEB application, i.e., the WEB-INF directory, so that the application server can read the deployment description file when the application to be deployed is subsequently deployed. Then, the attribute configuration tags corresponding to the file to be filtered are configured in the class loading configuration tag in the deployment description file. It can be understood that the deployment description file can also include the configuration parameters of the application to be deployed, URL mapping (URL, i.e., Uniform Resource Locator), Servlet and filter definitions.
[0049] It can be understood that, in this embodiment, configuring the attributes of the corresponding attribute configuration tag in the class loading configuration tag according to the file to be filtered may include: determining the file to be filtered in the file class library of the application to be deployed; configuring the attribute name of the corresponding attribute configuration tag in the class loading configuration tag to ignore loading and the attribute value to the file name of the file to be filtered according to the file to be filtered. In a specific embodiment, when deploying the application to be deployed, redundant JAR files in the file class library of the application to be deployed as files to be filtered have been pre-determined, then the attributes in the class loading configuration tag corresponding to the file to be filtered can be configured through the following code, wherein the JAR file is a software package file format, which is usually used to aggregate a large number of Java class files, related metadata and resource files into one file to develop Java platform application software or libraries:
[0050] <class-loader>
[0051] <property name="ignoreJars" value="jul-slf4j.jar,jasper.jar">< / property>
[0052] < / class-loader> ;
[0053] Specifically, <class-loader>Represents the class loading configuration tag. <property>It indicates the attribute configuration tag defined under the class loading configuration tag. name="ignoreJars" indicates that the attribute name is to ignore loading. value="jul-slf4j.jar,jasper.jar" indicates that jul-slf4j.jar,jasper.jar is the file name of the file to be filtered. It is understandable that the application server itself currently supports the class loading configuration tag. You can add the ignore loading JAR file attribute ignoreJars under the class loading tag. This attribute is a custom attribute that can be used to configure the JAR files that need to be ignored. Multiple JAR files are separated by commas.
[0054] In another specific implementation, before deploying the application to be deployed, it is not certain whether there are redundant JAR files in the file class library of the application to be deployed, so the attribute value corresponding to the attribute configuration tag with the attribute name of "ignore loading" in the class loading configuration tag can be set to empty, and the class loading configuration tag can be adjusted according to the actual deployment and access conditions, as shown in the following code:
[0055] <class-loader>
[0056] <property name="ignoreJars" value="">< / property>
[0057] < / class-loader> ;
[0058] in <class-loader>Represents the class loading configuration tag. <property>Represents the attribute configuration tag defined under the class loading configuration tag. name="ignoreJars" indicates that the attribute name is ignore loading, and value="" indicates that the file to be filtered is empty.
[0059] It is understandable that the file class libraries of the application to be deployed include but are not limited to: Servlet and JSP (JavaServer Pages) related class libraries, log and monitoring related class libraries, and database connection pools.
[0060] Step S12: filtering the corresponding to-be-filtered files in the file class library of the to-be-deployed application based on the attribute name in the class loading configuration tag to obtain the remaining target files in the file class library.
[0061] In this embodiment, in order to obtain all the files to be filtered in the file library of the application to be deployed, the filtering of the corresponding files to be filtered in the file library of the application to be deployed based on the attribute name in the class loading configuration tag may include: using the application server to parse the deployment description file of the application to be deployed to obtain the class loading configuration tag; determining the attribute value corresponding to the attribute configuration tag whose attribute name in the class loading configuration tag is ignored loading; determining the file name of the corresponding file to be filtered according to the attribute value, and storing the file name of the file to be filtered in the preset ignored loading file array, and filtering the corresponding files to be filtered in the file library of the application to be deployed according to the preset ignored loading file array. Specifically, the application server parses the contents of the deployment description file one by one according to the format and structure of the deployment description file of the application to be deployed. If the file format of the deployment description file is incorrect, the content is missing or there is an error, the application server will prompt an exception or error. After parsing the deployment description file, the pre-configured class loading configuration tag can be obtained, and the attribute name in the attribute configuration tag of the class loading configuration tag is the tag whose attribute name is ignored loading, and then the attribute value corresponding to the tag whose attribute name is ignored loading is obtained, and the attribute value represents the file name of the file to be filtered. And declare an array in advance as the ignore loading file array, specify the type and dimension of the ignore loading file array and determine the size of the ignore loading file array, then access the specific position in the ignore loading file array through the index, and store the file name of the file to be filtered as an element in the array at the corresponding position. The index usually starts from 0, indicating the first element of the array. When storing the file name of the file to be filtered, it is necessary to ensure that the index value is within the legal range of the ignore loading file array. If the index value exceeds the size of the ignore loading file array, an array out of bounds exception or undefined behavior will be displayed. Then, the files to be filtered in the file class library of the application to be deployed can be filtered according to the ignore loading file array.
[0062] In a specific implementation, the application server parses the deployment description file inforsuite-web.xml of the application to be deployed, obtains the class loading configuration tag, reads the attribute name configured by the ignoreJars attribute as the file name of the JAR file to be filtered that is ignored for loading, and stores the file name of the file to be filtered in a preset ignored loading file array.
[0063] It should be further pointed out that, in this embodiment, filtering the corresponding files to be filtered in the file class library of the application to be deployed according to the preset ignored loading file array may include: judging whether the file name of each file in the file class library of the application to be deployed is consistent with the file name of the files to be filtered in the preset ignored loading file array; according to the judgment result, taking the files in the file class library of the application to be deployed whose file names are consistent with the file names of the files to be filtered in the preset ignored loading file array as the files to be filtered; filtering the files to be filtered in the file class library of the application to be deployed to obtain the remaining target files in the file class library.
[0064] In a specific implementation, in order to filter the files to be filtered in the JAR file class library of the WEB application to be deployed, first use the new keyword to create the WEB-INF / lib directory file class, that is, the file class of the JDK (JDK, i.e., Java Development Kit, Java Development Kit), and then call the filter file method of the JDK file class. Specifically, by calling the filter file method, all JAR files in the JAR file class library of the WEB application to be deployed are traversed, and then the file name of each JAR file is compared with the file name of the file to be filtered in the preset ignored loading file array. If the comparison is successful, the JAR file is filtered out, that is, by calling the filter file method of the JDK file class, the files to be filtered in the JAR file class library of the WEB application to be deployed are finally excluded, and the remaining target files in the JAR file class library are obtained.
[0065] Step S13: adding the target file in the file class library to the class loader corresponding to the application to be deployed, reading the target file in the class loader, and deploying the application to be deployed to the corresponding application server based on the read target file.
[0066] In this embodiment, in order to find the files required for the application to run and ensure the normal operation of the application, the target file in the file class library is added to the class loader corresponding to the application to be deployed, which may include: creating the class loader corresponding to the application to be deployed, and calling the preset file adding method in the class loader to add the target file in the file class library to the class path corresponding to the class loader. Specifically, in order to ensure that each application can run in a relatively independent environment and avoid class conflicts and version incompatibility problems, the application server creates a corresponding class loader for the application to be deployed, which is used to load class classes or resource files, and then traverses all JAR files except the files to be filtered in the JAR file class library of the WEB application, and calls the preset file adding method in the class loader corresponding to the application to be deployed to add the target file in the file class library to the class path corresponding to the class loader. In this way, WebappClassLoader has been configured according to the class loading attribute tag, and the ignored JAR files are excluded from the class path, that is, when searching for class files or resource files later, the partially ignored JAR files are no longer searched, and finally the application to be deployed is deployed to the corresponding application server based on the read target files. It should be noted that when adding the target file in the file library to the class loader, it should be ensured that the target file in the file library is compatible with the application to be deployed and will not cause class conflicts or version incompatibility issues. There are multiple ways to add preset files.
[0067] In a specific implementation, you first need to determine the WEB-INF / lib directory under the directory of the WEB application to be deployed, that is, the standard directory under the WEB-INF directory, which contains multiple JAR files required for the WEB application to be deployed at run time, and then copy the target file in the file class library to the WEB-INF / lib directory. In some specific cases, you need to restart the application server to make the changes to the file take effect.
[0068] In another specific implementation, for certain specific application servers, the external JAR file may be added to the class path corresponding to the class loader by modifying the configuration file. After modifying the configuration file, the application server is restarted to make the changes to the configuration file take effect.
[0069] As can be seen from the above, in this embodiment, the attributes of the corresponding attribute configuration tag in the class loading configuration tag can be first configured according to the file to be filtered; wherein, the class loading configuration tag is a configuration tag in the deployment description file of the application to be deployed, and the attributes include attribute names and attribute values; then, based on the attribute names in the class loading configuration tag, the corresponding files to be filtered in the file class library of the application to be deployed are filtered to obtain the remaining target files in the file class library, and the target files in the file class library are added to the class loader corresponding to the application to be deployed, so as to read the target files in the class loader, and deploy the application to be deployed to the corresponding application server based on the target files. As can be seen from the above, before the application is deployed, the present embodiment first configures specific attributes for the file to be filtered, and then when the application is deployed, the corresponding file to be filtered in the file class library of the application to be deployed is obtained based on the attributes of the file to be filtered, and the file to be filtered is filtered out from the file class library of the application to be deployed. In this way, when the application to be deployed searches for class files or resource files from the file class library, the file to be filtered is no longer searched. That is, in the process of deploying the application, the present embodiment can parse the inforsuite-web.xml deployment description file, read the class loading attribute tag, read the name of the JAR file to be ignored by the ignoreJars attribute, and store it in the ignore loading file array. The file class library of the WEB application JAR excludes this part of the JAR files to be ignored. In this way, when searching for class files or resource files from the file class library, only the remaining target files except the file to be filtered in the file class library are searched, and the operation of deploying the application to be deployed to the corresponding application server is completed based on the target files. Through the above process, the present embodiment can ignore the search for redundant files in the deployment stage or the access stage, thereby ensuring the normal and stable operation of the application.
[0070] Through the above embodiment, the files to be filtered in the file library of the application to be deployed can be filtered, and the remaining target files in the file library can be added to the class loader. The application to be deployed can be deployed to the corresponding server based on the target files. Next, in order to further determine whether the application to be deployed is successfully deployed and can be accessed normally, see Figure 2 As shown, the embodiment of the present invention further discloses an application deployment method, which may include:
[0071] Step S21: calling a preset file reading method in the class loader to read a target file, and deploying an application to be deployed based on the target file.
[0072] It can be understood that during the deployment phase of the application to be deployed, the application to be deployed calls the preset file reading method from the class loader to read the target file in the class path corresponding to the class loader, that is, the application to be deployed searches for the class files or resource files required for runtime from the class path of the WebappClassLoader, wherein the JAR file to be filtered has been excluded from the JAR file class library of the application to be deployed and is no longer in the class path of the WebappClassLoader. Then, the running result of the application to be deployed is obtained, and whether the application to be deployed is successfully deployed is determined based on the running result.
[0073] Step S22: If the deployment of the application to be deployed fails, determine the first abnormal file in the target file based on the deployment failure result, and modify the attribute configuration tag with the attribute name of "ignore loading" in the class loading configuration tag according to the file name of the first abnormal file, so as to continue to deploy the application to be deployed to the corresponding application server according to the modified target attribute configuration tag.
[0074] In this embodiment, if there are unfiltered files to be filtered in the target files in the file library of the application to be deployed, resulting in the existence of files to be filtered in the class loader corresponding to the application to be deployed, then when the application to be deployed calls the preset file reading method in the class loader to read the target file during operation, the file to be filtered is identified, so that the application to be deployed executes the relevant program logic in the file to be filtered, which in turn causes an abnormality in the operation of the application to be deployed, and the deployment of the application to be deployed is determined to have failed. It is necessary to obtain the first abnormal file in the target file according to the error report of the deployment failure result, and add a file name of the first abnormal file at the end of the attribute value corresponding to the attribute configuration tag whose attribute name is to ignore loading in the class loading configuration tag, and continue to deploy the application to be deployed to the corresponding application server according to the modified target attribute configuration tag until it is determined that the application to be deployed is successfully deployed. In a specific implementation, there are JAR files to be filtered in the JAR file class library of the WEB application to be deployed. During the operation of the application to be deployed, the class files or resource files in this part of the JAR files to be filtered are identified by calling the class file search method or resource file search method of WebappClassLoader, resulting in the execution of the relevant program logic in this part of the JAR files to be filtered, which in turn causes an exception in the operation of the application to be deployed. At this time, it is necessary to obtain the first exception file in the target file according to the actual deployment error, and configure the file name of the first exception file to the ignoreJars attribute of inforsuite-web.xml, so as to filter the first exception file from the JAR file class library of the WEB application to be deployed, and continue to deploy the application to be deployed until the deployment is successful.
[0075] Step S23: If the application to be deployed is deployed successfully, access the application to be deployed in the application server, and read the target file in the class loader through the application to be deployed.
[0076] It is understandable that, in the deployment phase of the application to be deployed, the application to be deployed calls the preset file reading method from the class loader to read the files required for the application to be deployed to run in the class path corresponding to the class loader, and obtains the normal operation result of the application to be deployed, then confirms that the application to be deployed is deployed successfully, and accesses the application to be deployed in the application server. Specifically, first, it is necessary to confirm the IP address or domain name of the application server, obtain the port number of the application server, and ensure that the network is connected. According to the type of application server and the protocol of the application to be deployed, select and configure the appropriate client software, then navigate to enter and start the application to be deployed, and confirm whether the application to be deployed is successfully started by checking the log file or console output. Finally, enter the IP address or domain name of the application server and the port number of the application to be deployed in the browser or other client software to enter the access interface. At this time, the application to be deployed will read the target file in the class loader to complete the access to the application to be deployed, that is, in the access phase, the WEB application to be deployed searches for the class files or resource files required for runtime from the class path of WebappClassLoader.
[0077] In a specific implementation, if before accessing the application to be deployed, the attribute configuration tag in the class loading configuration tag is modified to obtain the target attribute configuration tag due to the failure of deployment of the application to be deployed, and the application to be deployed is successfully deployed to the corresponding application server based on the target attribute configuration tag, then the target file is the target file obtained after filtering out the first abnormal file.
[0078] In another specific implementation, if before accessing the application to be deployed, the application to be deployed is directly deployed to the corresponding application server without modifying the attribute configuration tag in the class loading configuration tag, then the target file is the target file in the unmodified class loader.
[0079] Step S24: If access to the application to be deployed fails, uninstall the application to be deployed, determine the second abnormal file in the target file based on the access failure result, and modify the target attribute configuration tag according to the file name of the second abnormal file, so as to redeploy the application to be deployed to the corresponding application server according to the modified target attribute configuration tag.
[0080] In this embodiment, when accessing the application to be deployed, if the application to be deployed identifies the file to be filtered when reading the target file, causing the application to be deployed to execute the relevant program logic in the file to be filtered, thereby causing the application to be deployed to run abnormally, then it is determined that the access to the application to be deployed has failed. After that, it is necessary to uninstall the application to be deployed, and based on the error report of the access failure result, determine the second abnormal file in the target file currently read, and then modify the class loading configuration tag according to the second abnormal file, and redeploy the application to be deployed to the corresponding application server based on the modified class loading configuration tag.
[0081] In a specific implementation, if before accessing the application to be deployed, the attribute configuration tag in the class loading configuration tag is modified to obtain the target attribute configuration tag due to the failure of deployment of the application to be deployed, and the application to be deployed is successfully deployed to the corresponding application server based on the target attribute configuration tag, then the target attribute configuration tag is modified according to the file name of the second exception file, so as to solve the abnormal problems occurring in the operation of the WEB application according to the modified target attribute configuration tag, and the application to be deployed is redeployed to the corresponding application server until the application to be deployed is accessed successfully.
[0082] In another specific implementation, if before accessing the application to be deployed, the application to be deployed is directly deployed to the corresponding application server without modifying the attribute configuration tag in the class loading configuration tag, then the attribute configuration tag in the class loading configuration tag is modified according to the file name of the second exception file, so as to solve the abnormal problems occurring in the operation of the WEB application according to the modified attribute configuration tag, and redeploy the application to be deployed to the corresponding application server until the access to the application to be deployed is successful.
[0083] As can be seen from the above, this embodiment reads the target file when deploying the application to be deployed, and determines whether the application to be deployed is successfully deployed based on the reading result. If the deployment of the application to be deployed fails, the first abnormal file in the target file is determined, the attribute configuration label is modified according to the first abnormal file, and the deployment of the application to be deployed is completed based on the target attribute configuration label obtained after the modification. After the deployment is successful, the application to be deployed is accessed, and the current target file is read again to determine whether the application to be deployed can be successfully accessed. If the access to the application to be deployed fails, the second abnormal file in the current target file is determined and the target attribute configuration label is modified based on the second abnormal file. In this way, the running result of the application to be deployed is obtained by reading the target file in the class loader multiple times to determine whether the application to be deployed is successfully deployed and can be accessed normally, thereby avoiding the failure of deployment and access of the application to be deployed due to incomplete filtering of the files to be filtered.
[0084] See also Figure 3 The deployment process of a WEB application, the embodiment of the present invention further discloses a specific application deployment method, which may include: first, it is necessary to configure a standard deployment description file of the WEB application, namely, inforsuite-web.xml, then create a WebappClassLoader, namely, a class loader, and read the standard deployment description file, in the deployment phase, the WEB application searches for class files or resource files to obtain an application deployment result, if the application deployment fails, then according to the error prompt, reconfigure the standard deployment description file, and jump to the step of reading the standard deployment description file, until the application is successfully deployed, then in the access phase, the WEB application searches for class files or resource files to obtain an application access result, if the access fails, then after uninstalling the application, reconfigure the standard deployment description file according to the error prompt, and jump to the step of reading the standard deployment description file, until the application is successfully deployed and accessed. As can be seen above, the attribute ignoreJars configured in the inforsuite-web.xml deployment descriptor file of the WEB application can configure the JAR files to be filtered. The application server parses this configuration and excludes the configured JAR files to be filtered from the class path of WebappClassLoader, so that when searching for class files or resource files later, this part of the JAR files to be filtered will no longer be searched, thereby successfully deploying the WEB application to the corresponding server. In this way, WEB applications can be developed according to standard specifications, solving the problem of abnormal operation of WEB applications caused by redundant JAR files, enhancing the compatibility and availability of the application server, ensuring the normal and stable operation of the application, making the subsequent operation and maintenance of the application server and WEB application simple and easy, and reducing the workload of the operation and maintenance personnel.
[0085] Accordingly, see Figure 4 As shown, the embodiment of the present invention further provides an application deployment device, which may include:
[0086] The tag configuration module 11 is used to configure the attributes of the corresponding attribute configuration tag in the class loading configuration tag according to the file to be filtered; the class loading configuration tag is a configuration tag in the deployment description file of the application to be deployed, and the attributes include attribute name and attribute value;
[0087] A file filtering module 12, configured to filter the corresponding to-be-filtered files in the file library of the application to be deployed based on the attribute name in the class loading configuration tag, and obtain the remaining target files in the file library;
[0088] The application deployment module 13 is used to add the target file in the file library to the class loader corresponding to the application to be deployed, read the target file in the class loader, and deploy the application to be deployed to the corresponding application server based on the read target file.
[0089] As can be seen from the above, in this embodiment, the attributes of the corresponding attribute configuration tag in the class loading configuration tag can be first configured according to the file to be filtered; wherein, the class loading configuration tag is a configuration tag in the deployment description file of the application to be deployed, and the attributes include attribute names and attribute values; then, based on the attribute names in the class loading configuration tag, the corresponding files to be filtered in the file class library of the application to be deployed are filtered to obtain the remaining target files in the file class library, and the target files in the file class library are added to the class loader corresponding to the application to be deployed, so as to read the target files in the class loader, and deploy the application to be deployed to the corresponding application server based on the target files. As can be seen from the above, before deploying the application, this embodiment first configures specific attributes for the file to be filtered, and then when deploying the application, based on the attributes of the file to be filtered, obtains the corresponding file to be filtered in the file library of the application to be deployed, and filters the file to be filtered from the file library of the application to be deployed. In this way, when the application to be deployed searches for class files or resource files from the file library, it no longer searches for the file to be filtered. That is, in the process of deploying the application, when searching for class files or resource files from the file library, this embodiment only searches for the remaining target files in the file library except the file to be filtered, and completes the operation of deploying the application to be deployed to the corresponding application server based on the target files. In this way, this embodiment can ignore the search for redundant files in the deployment stage or access stage through the above process, thereby ensuring the normal and stable operation of the application.
[0090] In some specific implementations, the label configuration module 11 includes:
[0091] A file determining unit, configured to determine the file to be filtered in the file library of the application to be deployed;
[0092] The tag configuration unit is used to configure the attribute name of the attribute configuration tag corresponding to the class loading configuration tag to ignore loading and the attribute value to the file name of the file to be filtered according to the file to be filtered.
[0093] In some specific implementations, the file filtering module 12 includes:
[0094] A tag acquisition unit, configured to parse the deployment description file of the application to be deployed by using the application server to obtain the class loading configuration tag;
[0095] An attribute value determination unit, used to determine an attribute value corresponding to an attribute configuration tag whose attribute name is to ignore loading in the class loading configuration tag;
[0096] A file filtering unit is used to determine the file name of the corresponding file to be filtered according to the attribute value, store the file name of the file to be filtered in a preset ignored loading file array, and filter the corresponding file to be filtered in the file class library of the application to be deployed according to the preset ignored loading file array.
[0097] In some specific implementations, the file filtering unit is specifically used to determine whether the file names of each file in the file class library of the application to be deployed are consistent with the file names of the files to be filtered in the preset ignore loading file array; according to the judgment result, the files in the file class library of the application to be deployed whose file names are consistent with the file names of the files to be filtered in the preset ignore loading file array are used as the files to be filtered; the files to be filtered in the file class library of the application to be deployed are filtered to obtain the remaining target files in the file class library.
[0098] In some specific implementations, the application deployment module 13 includes:
[0099] The first application deployment unit is used to create the class loader corresponding to the application to be deployed, and call a preset file adding method in the class loader to add the target file in the file class library to the class path corresponding to the class loader.
[0100] In some specific implementations, the application deployment module 13 includes:
[0101] A file reading unit, used for calling a preset file reading method in the class loader to read the target file, and deploying the application to be deployed based on the target file;
[0102] The second application deployment unit is used to determine the first abnormal file in the target file based on the deployment failure result if the deployment of the application to be deployed fails, and modify the attribute name in the class loading configuration tag to ignore the loading of the attribute configuration tag according to the file name of the first abnormal file, so as to continue to deploy the application to be deployed to the corresponding application server according to the modified target attribute configuration tag.
[0103] In some specific implementations, the application deployment device further includes:
[0104] An application access module, configured to access the application to be deployed in the application server if the application to be deployed is successfully deployed, and read the target file in the class loader through the application to be deployed;
[0105] A label modification module is used to uninstall the application to be deployed if access to the application to be deployed fails, and determine a second abnormal file in the target file based on the access failure result, and modify the target attribute configuration label according to the file name of the second abnormal file, so as to redeploy the application to be deployed to the corresponding application server according to the modified target attribute configuration label.
[0106] Furthermore, the present application also discloses an electronic device. Figure 5 This is a structural diagram of an electronic device 20 according to an exemplary embodiment, and the content in the figure cannot be regarded as any limitation on the scope of use of this application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 is used to store a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the application deployment method disclosed in any of the aforementioned embodiments. In addition, the electronic device 20 in this embodiment may specifically be an electronic computer.
[0107] In this embodiment, the power supply 23 is used to provide working voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and the external device, and the communication protocol it follows is any communication protocol that can be applied to the technical solution of the present application, and is not specifically limited here; the input and output interface 25 is used to obtain external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs and is not specifically limited here.
[0108] In addition, the memory 22, as a carrier for storing resources, can be a read-only memory, a random access memory, a disk or an optical disk, etc. The resources stored thereon can include an operating system 221, a computer program 222, etc., and the storage method can be temporary storage or permanent storage.
[0109] The operating system 221 is used to manage and control the hardware devices and computer programs 222 on the electronic device 20, which can be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program that can be used to complete the application deployment method performed by the electronic device 20 disclosed in any of the aforementioned embodiments, the computer program 222 can further include a computer program that can be used to complete other specific tasks.
[0110] Furthermore, the present application also discloses a computer-readable storage medium for storing a computer program; wherein the computer program, when executed by a processor, implements the aforementioned disclosed application deployment method. For the specific steps of the method, reference may be made to the corresponding contents disclosed in the aforementioned embodiments, and no further description will be given here.
[0111] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0112] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0113] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0114] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the statement "comprises a..." does not exclude the presence of other identical elements in the process, method, article or device including the element.
[0115] The technical solution provided by the present application is introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for general technicians in this field, according to the idea of the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.< / property> < / property>
Claims
1. An application deployment method, characterized in that: include: Load the attributes of the corresponding attribute configuration tag in the configuration tag according to the file configuration class to be filtered; The class loading configuration tag is a configuration tag in the deployment description file of the application to be deployed, and the attributes include an attribute name and an attribute value; Filter the corresponding to-be-filtered files in the file class library of the application to be deployed based on the attribute name in the class loading configuration tag to obtain the remaining target files in the file class library; The target file in the file class library is added to the class loader corresponding to the application to be deployed, and the target file in the class loader is read, and the application to be deployed is deployed to the corresponding application server based on the read target file.
2. The application deployment method according to claim 1, characterized in that: The attributes of the attribute configuration tag corresponding to the attribute configuration tag in the configuration tag loaded according to the configuration class of the file to be filtered include: Determining the file to be filtered in the file library of the application to be deployed; According to the file to be filtered, the attribute name of the attribute configuration tag corresponding to the class loading configuration tag is configured to ignore loading, and the attribute value is configured to the file name of the file to be filtered.
3. The application deployment method according to claim 2, characterized in that: The filtering the corresponding to-be-filtered files in the file class library of the to-be-deployed application based on the attribute name in the class loading configuration tag includes: Parsing the deployment description file of the application to be deployed using the application server to obtain the class loading configuration tag; Determine the attribute value corresponding to the attribute configuration tag whose attribute name in the class loading configuration tag is to be ignored for loading; Determine the file name of the corresponding file to be filtered according to the attribute value, store the file name of the file to be filtered in a preset ignored loading file array, and filter the corresponding file to be filtered in the file class library of the application to be deployed according to the preset ignored loading file array.
4. The application deployment method according to claim 3, characterized in that: The filtering the corresponding to-be-filtered files in the file class library of the to-be-deployed application according to the preset ignored-loading file array comprises: Determine whether the file names of each file in the file class library of the application to be deployed are consistent with the file names of the to-be-filtered files in the preset ignored loading file array; According to the judgment result, a file in the file class library of the application to be deployed whose file name is consistent with the file name of the file to be filtered in the preset ignored loading file array is used as the file to be filtered; The to-be-filtered files in the file library of the to-be-deployed application are filtered to obtain remaining target files in the file library.
5. The application deployment method according to claim 1, characterized in that: The step of adding the target file in the file class library to the class loader corresponding to the application to be deployed includes: The class loader corresponding to the application to be deployed is created, and a preset file adding method in the class loader is called to add the target file in the file class library to the class path corresponding to the class loader.
6. The application deployment method according to any one of claims 1 to 5, characterized in that: The reading of the target file in the class loader and deploying the application to be deployed to a corresponding application server based on the read target file includes: Calling a preset file reading method in the class loader to read the target file, and deploying the application to be deployed based on the target file; If the deployment of the application to be deployed fails, the first abnormal file in the target file is determined based on the deployment failure result, and the attribute name in the class loading configuration tag is modified to the attribute configuration tag that is ignored for loading according to the file name of the first abnormal file, so as to continue to deploy the application to be deployed to the corresponding application server according to the modified target attribute configuration tag.
7. The application deployment method according to claim 6, characterized in that: After reading the target file in the class loader and deploying the to-be-deployed application to the corresponding application server based on the read target file, the method further includes: If the application to be deployed is successfully deployed, accessing the application to be deployed in the application server, and reading the target file in the class loader through the application to be deployed; If access to the application to be deployed fails, the application to be deployed is uninstalled, and a second abnormal file in the target file is determined based on the access failure result, and the target attribute configuration tag is modified according to the file name of the second abnormal file, so that the application to be deployed is redeployed to the corresponding application server according to the modified target attribute configuration tag.
8. An application deployment device, characterized in that: include: The tag configuration module is used to configure the attributes of the tag according to the corresponding attributes in the configuration tag of the file to be filtered configuration class loading; The class loading configuration tag is a configuration tag in the deployment description file of the application to be deployed, and the attributes include an attribute name and an attribute value; A file filtering module, used to filter the corresponding to-be-filtered files in the file class library of the to-be-deployed application based on the attribute name in the class loading configuration tag, to obtain the remaining target files in the file class library; The application deployment module is used to add the target file in the file library to the class loader corresponding to the application to be deployed, read the target file in the class loader, and deploy the application to be deployed to the corresponding application server based on the read target file.
9. An electronic device, characterized in that: include: Memory, used to store computer programs; A processor, configured to execute the computer program to implement the application deployment method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: Used to store a computer program; wherein, when the computer program is executed by a processor, the application deployment method according to any one of claims 1 to 7 is implemented.
Citation Information
Cited By
Loading method for ignored resources of application server and related equipment
CN120821513A