[go: up one dir, main page]

CN120406920A - A method for quickly switching the underlying network engine of the program based on the SpringBoot framework - Google Patents

A method for quickly switching the underlying network engine of the program based on the SpringBoot framework

Info

Publication number
CN120406920A
CN120406920A CN202510928561.6A CN202510928561A CN120406920A CN 120406920 A CN120406920 A CN 120406920A CN 202510928561 A CN202510928561 A CN 202510928561A CN 120406920 A CN120406920 A CN 120406920A
Authority
CN
China
Prior art keywords
custom
network engine
class
layout
springboot
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202510928561.6A
Other languages
Chinese (zh)
Other versions
CN120406920B (en
Inventor
包恩伟
董兴荣
蒋骥
刘志强
薛圣乐
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhejiang Baorong Technology Co ltd
Original Assignee
Zhejiang Baorong Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhejiang Baorong Technology Co ltd filed Critical Zhejiang Baorong Technology Co ltd
Priority to CN202510928561.6A priority Critical patent/CN120406920B/en
Priority claimed from CN202510928561.6A external-priority patent/CN120406920B/en
Publication of CN120406920A publication Critical patent/CN120406920A/en
Application granted granted Critical
Publication of CN120406920B publication Critical patent/CN120406920B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Stored Programmes (AREA)

Abstract

本发明为计算机软件技术领域,本发明的目的是解决SpringBoot框架下多引擎无法通过自动配置来适应不同场景的问题。对此本发明提供基于SpringBoot框架的快速切换程序底层网络引擎的方法,包括分离的运行工程和打包工程,通过自定义启动入口类、自定义Layout布局管理器以及定制ClassLoader完成打包工程,并通过使用自定义Layout布局管理器来完成底层网络引擎的快速切换。该方案通过运行时动态依赖管理,无需预打包多版本或修改代码,实现了网络引擎的零成本切换,适配存在一定差异的国内外引擎的快速适配需求,避免了多版本打包的存储与维护开销。

The present invention belongs to the field of computer software technology, and the purpose of the present invention is to solve the problem that multiple engines under the SpringBoot framework cannot adapt to different scenarios through automatic configuration. To this end, the present invention provides a method for quickly switching the underlying network engine of a program based on the SpringBoot framework, including a separated running project and a packaging project, completing the packaging project through a custom startup entry class, a custom Layout layout manager, and a custom ClassLoader, and completing the rapid switching of the underlying network engine by using a custom Layout layout manager. This solution achieves zero-cost switching of network engines through runtime dynamic dependency management, without the need to pre-package multiple versions or modify code, and adapts to the rapid adaptation requirements of domestic and foreign engines with certain differences, avoiding the storage and maintenance overhead of multi-version packaging.

Description

Method for rapidly switching program bottom layer network engine based on SpringBoot framework
Technical Field
The invention relates to the technical field of computer software, in particular to a method for rapidly switching a program bottom layer network engine.
Background
SpringBoot is an open source Java development framework based on a Spring framework, and aims to simplify the initial construction and development process of Spring applications. It reduces the configuration burden on the developer by providing default configuration and automation tools, making it possible to build production-level applications quickly.
However, the "black box" characteristic of automatic configuration causes difficult debugging, and a developer needs to understand the underlying mechanism deeply to solve the customization requirement, so that the learning curve for novice is higher. Although SpringBoot reduces the configuration complexity, starting is convenient and fast, due to the fact that a redundant library is introduced, the application volume expansion and the starting time are prolonged, and particularly the memory occupation problem is more obvious in a resource-limited scene. The performance of the embedded server in a high concurrency scenario may be weaker than an independently deployed optimization scheme (such as the nmginx+tomcat combination), and the initialization step of automatic configuration may slow down the start-up speed, requiring additional optimization for the scenario with extreme performance requirements.
For the above problems, it is the most ideal state to set up multiple sets of network engines to cope with different scenarios. In actual use, one of the web engines is designated for use SpringBoot from the already set web engines. In reality, however, if a plurality of network engines exist simultaneously under SpringBoot, the SpringBoot program will automatically find a conflict and report an error when started, and at this time, the service program will not be started normally. In the prior art, for example, patent number CN201110204556.9 discloses an exception handling method in a mixed mode execution engine, which aims at a plurality of mixed operation modes of execution engines existing in the existing Java virtual machine, and corresponding exception handling strategies are formulated according to different characteristics of different execution engines, so that a novel exception handling method is provided, which comprises searching a Catch block which is matched first, obtaining information of a Catch block which is matched with a certain exception and a function where the Catch block is located through function call, changing an execution flow to the Catch block, and simultaneously, returning stack information to a stack frame corresponding to the function where the Catch block is located layer by layer. The invention solves the problem of exception handling in Java virtual machines under various execution engines. However, this technique requires the use of virtual machine techniques, and is not capable of processing until an abnormality occurs, rather than actively preventing the occurrence of an abnormality. There are also methods in the prior art for switching engines, such as modifying and adjusting the pore xml file, or adjusting the JVM startup parameters, but these methods all require manual setting by a technician, and the setting parameters need to be adjusted for different applications for different engines. The existing methods have high requirements on the capabilities of technicians. In addition, most engines in the prior art are customized standards of foreign manufacturers, enterprises begin to manufacture corresponding engines in China at present, but compatibility between the engines also has some problems, and particularly, the abnormal probability can be increased in the engine switching process.
Disclosure of Invention
Aiming at the defects of the prior art, the invention aims to solve the problem that multiple engines under SpringBoot frames cannot adapt to different scenes through automatic configuration.
The invention relates to a method for quickly switching a program bottom layer network engine based on SpringBoot framework, which comprises two separate projects, namely an operation project and a packaging project, wherein the operation project comprises a Layout realization class and a dynamic filtering rule engine, the packaging project comprises a built-in Layout factory and a class dynamic injection mechanism, the Layout factory packages business projects into customized classes through plug-ins based on official main class Layout, the packaging project is completed through custom starting of an entry class, custom Layout manager and custom ClassLoader, and quick switching of the bottom layer network engine is completed through use of the custom Layout manager.
Preferably, the custom starting entry class inherits JarLauncher and rewrites createClassLoader, dynamically eliminates dependent packets of non-target engines according to system parameters, and identifies JAR packets of different engines through a predefined dependency mapping table to realize accurate filtering. JarLauncher is a starter class introduced in JavaSE and higher for optimizing the starting mode of JAR packages. The Java type path management method belongs to a part of a Java modularized system, and mainly solves the problem of class path management when a traditional JAR package is started. And createClassLoader refers to a method of creating a custom class loader (ClassLoader). The class loader is one of the core components of the JVM and is responsible for dynamically loading Java classes into memory.
Preferably, the content after the packaging engineering is compiled is pushed to a Maven private service for subsequent engineering. The Maven private service refers to a private server built based on Maven warehouse management specifications and is used for storing JAR packages, plugins and custom components of project dependence. It is open only to internal team and can store internal project components, third party closed source dependencies or proxy caches of public warehouses.
Preferably, the custom Layout manager, the extension JarLayout, embeds the custom startup class into the final JAR package in the packaging stage, ensures that the startup entry points to custom logic, combines Maven plug-in configuration, covers default packaging behavior, realizes Layout logic injection, performs parameterized switching in the deployment stage, does not need recompilation or pre-packaging of multiple versions, and automatically eliminates conflict dependence by starting a parameter-specified target engine.
Preferably, the filter package is defined when customizing the ClassLoader, specifically, static application_server_ DEPENDENCIES is defined in the related class, and dependency package lists of different network engines are respectively configured.
Preferably, the method for customizing the ClassLoader also needs to rewrite the method, and specifically comprises the steps of obtaining the network engine type from a start parameter network. Engine. Type, counting a dependent packet prefix set excludedJarNamePrefixs of a non-designated network engine, traversing the URL array, filtering unnecessary URLs according to the comparison of jar packet names and prefix sets, and finally calling a parent class method by using the filtered URL array to create the ClassLoader. By specifying the network.engine type in the startup parameters, other network engine dependent packets can be excluded and network engine switching can be achieved. excludedJarNamePrefixs is a configuration parameter common in Maven, gradle, or custom build scripts that is used to exclude JAR packages for a particular prefix.
Preferably, the SpringBoot-supported network engine includes at least two of Tomcat, jetty, undertow, netty. Tomcat is an Apache foundation open source project, the community is active, the ecology is extremely rich, and almost all JavaWeb frameworks are compatible with Tomcat.
Jetty is an open source project maintained by Eclipse foundation, well integrated with Spring, quarkus, etc., framework, often used in scenarios where asynchronous features are required.
Undertow developed by RedHat is a default container of WildFly application server, is deeply integrated with OpenShift cloud platform, and ecologically depends on RedHat technology stack.
Netty is also an open source project, maintained by JBoss, which is the underlying foundation for many high performance middleware, suitable for development teams with customization needs.
Preferably, the SpringBoot-supported network engine further includes TongWeb. TongWeb is an enterprise-level Java application server, belongs to a domestic middleware product, and is mainly used for supporting deployment and operation of enterprise-level Web applications. Its location is similar to OracleWebLogic, IBMWebSphere, supports the JavaEE (now JakartaEE) specification, provides a complete application container environment, including enterprise-level functions of Servlet containers, EJB containers, JMS services, transaction management, etc.
The invention also relates to an electronic device comprising:
a memory for storing a computer program;
and the processor is used for realizing the method for rapidly switching the program bottom layer network engine based on SpringBoot frames when executing the programs stored in the memory.
The invention also relates to a computer readable storage medium having stored therein a computer program which when executed by a processor implements a method for switching a program-based network engine fast based on SpringBoot framework.
The scheme divides the complete engineering flow into two relevant stages of operation engineering and packaging engineering, and the maintainability, expansibility and flexibility of the system are finally improved through responsibility separation of the development stage, plug-in customization of the packaging stage and dynamic dependency management of the operation stage. Especially, by running dynamic dependency management, the zero-cost switching of the network engine is realized without pre-packing multi-version or modifying codes, the quick adaptation requirement of the domestic and foreign engines with certain difference is adapted, and the storage and maintenance expenditure of multi-version packing is avoided. By adopting the technical scheme, the invention solves the problems of complexity and technical thresholds of technical schemes such as modifying the pore file or manually mounting the dependent catalogue in the traditional scheme, reduces the deployment risk and greatly improves the flexibility and portability of the framework.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the embodiments or the description of the prior art will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention.
FIG. 1 is a flow chart of a method for switching a program bottom layer network engine rapidly based on SpringBoot framework of the present invention;
Fig. 2 is a schematic flow chart of the method for implementing the main steps of the embodiment of the present invention based on SpringBoot framework fast switching program bottom layer network engine.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. It is to be understood that the specific embodiments described herein are merely illustrative of the relevant content and not limiting of the present disclosure.
Various network engines are preset in SpringBoot frames, but in actual use, one network engine must be designated for SpringBoot, if a plurality of network engines exist at the same time, the SpringBoot program automatically discovers conflict and reports errors when started, and at the moment, the business program cannot be started normally.
For example, we do not exclude that the Tomcat network engine directly increases the Jetty network engine's dependence on the default Tomcat, corresponding to the complete dependence as follows:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
after start-up, the error is reported as follows:
2025-03-10 13:47:37.163
ERROR 7060 o.s.boot.SpringApplication
[main]: Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serverEndpoint' defined in class path resource;
it is apparent that this increase in the reliance on the Jetty network engine is not normally used.
In order to embody the inventive aspects of the present invention, the applicant compared it with the prior art solutions. First, two conventional schemes existing in the prior art will be described:
prior Art 1. Adjust the pom.xml File
Some existing solutions are to manually remove the default Tomcat network engine dependency while adding new network engine dependencies when new network engines need to be used by explicitly modifying the dependencies of the engineering dependency declaration file pon.
Examples are as follows:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
From the foregoing, it can be seen that this approach is achieved by explicitly excluding the Tomcat network engine by the developer during the development phase, while introducing the Jetty network engine's declaration, at which point the network engine can be switched.
However, since the specific network engine required by the client in the deployment stage cannot be predicted in advance in the development stage, the scheme can only be used when the initial engine is unsatisfied for reworking or modifying, and the network engine cannot be switched in real time in the deployment stage.
If a corresponding packet is formed for each network engine in the development stage in advance, the packing cost and the file storage cost rise exponentially, and the requirements of the business are not met.
Scheme 2 in the prior art, adjusting JVM Start parameters
Other solutions exist at present, wherein all network engine dependent packages are removed in advance when packaging is adopted, the package which is made does not contain any network engine dependent package, a program is issued, then an implementation personnel designates an extra dependent catalog by means of a starting parameter of the JVM in the deployment stage of a client site, and a specific network engine dependent package is placed in the catalog according to the actual requirement of the client, and examples are as follows:
java -Dloader.paths=libs -jar your-app.jar
At this time, a client-specified network engine dependency package is placed under the libs directory, and the objective can be achieved.
Although the network engine can be flexibly switched in the deployment stage, the problem is that deployment personnel are required to know the corresponding dependent package file, correctly find the dependent package file, upload and download the file on the deployment site and correctly edit the starting script according to the requirements of clients, the technical capability requirements of the deployment personnel are extremely high, the steps are more and very troublesome, the whole program is started in error due to the error of any step, and the maintenance cost of the whole system is very high.
As shown in figure 1, aiming at the problems existing in the prior art, the invention adopts a specific scheme that a method for quickly switching a program bottom layer network engine based on SpringBoot frames is provided, and comprises two separated projects, namely an operation project and a packaging project, wherein the operation project comprises a Layout realization class and a dynamic filtering rule engine, the packaging project comprises a built-in Layout factory and a class dynamic injection mechanism, the Layout factory packages business projects into customized classes through plug-ins based on official main class Layout, the packaging project is completed through custom starting an entry class, custom Layout manager and custom ClassLoader, and quick switching of the bottom layer network engine is completed through using the custom Layout Layout manager. Defining filtering package when customizing ClassLoader, defining static application_SERVER_ DEPENDENCIES in related class, and configuring dependency package list of different network engines respectively. The method specifically comprises the steps of obtaining a network engine type from a start parameter network.engine.type, counting a dependent packet prefix set excludedJarNamePrefixs of a non-designated network engine, traversing a URL array, filtering unnecessary URLs according to the comparison of jar packet names and the prefix set, and finally calling a parent class method by using the filtered URL array to create the ClassLoader. And pushing the content which completes the packaging project to a Maven private service after compiling, and providing for the subsequent project. The custom start entry class inheritance JarLauncher and the method of rewriting createClassLoader dynamically exclude dependent packages of non-target engines according to system parameters, and identify JAR packages of different engines through a predefined dependency mapping table. The custom Layout manager is expanded JarLayout, the custom starting class is embedded into the final JAR package in the packaging stage, the starting entry is ensured to point to custom logic, the default packaging behavior is covered by combining with Maven plug-in configuration, the Layout logic injection is realized, the parameterization switching is carried out in the deployment stage, and the target engine is specified through starting parameters, so that the conflict dependence is automatically eliminated.
The SpringBoot-supported network engine includes at least two of Tomcat, jetty, undertow, netty and also includes TongWeb.
The relevant terms therein need to be explained here:
the running engineering is responsible for the actual running logic of the application program and comprises two core components, namely a layout realization class and a dynamic filtering rule engine.
Layout implementation class, defining the whole structure and component relation of application, such as page layout, service layer and interaction mode of data layer.
Dynamic filtering rules engine-a network engine class that dynamically filters or eliminates specific dependencies at runtime based on conditions, e.g., decides whether to load Tomcat or TongWeb based on startup parameters.
Packaging engineering, which is to focus on the construction and packaging process of the application and comprises a built-in layout factory and a class dynamic injection mechanism.
The built-in layout factory converts business engineering into a customized class structure through a plug-in based on Spring official main class layout, and ensures that the packaged application meets specific deployment requirements.
And the class dynamic injection mechanism is used for injecting custom components such as a starting class and a layout manager into a final JAR package in a packaging stage to replace default implementation.
The official main class layout refers to SpringBoot default application starting structure, and uses the main class annotated by @ SpringBootApplication as an entry to start the application context through the springapplication. Based on this, the layout factory realizes customized packaging by expanding or modifying its behavior.
The custom Layout manager, expansion JarLayout, springBoot default Layout policy, is used to implement embedded custom startup classes, or modify the packing structure and support parameterized switching during the packing phase.
Embedding custom boot classes, namely embedding custom boot entry classes into META-INF/MANIFEST.MF of the final JAR package, and covering default boot logic.
Modifying the packing structure, namely adjusting the directory organization in the JAR package to ensure that the dependency is loaded in an expected manner.
Parameterized switching, namely, through Maven plug-in configuration, the layout logic can be dynamically adjusted through starting parameters in a deployment stage.
Customization ClassLoader, classLoader is a custom class loader that implements dependency filtering through static dependency lists and URL filtering.
Static dependency list the dependent package names of different network engines, like servlet-api. Jar of Tomcat, tangweb. Jar of TongWeb, are predefined by application_server_ DEPENDENCIES constant.
Application_server_ DEPENDENCIES, a static constant, a list of dependent package names for different APPLICATION SERVER network engines.
And (3) URL filtering, namely traversing all URLs to be loaded when the method of createClassLoader () is rewritten, and eliminating the dependent packet prefix of the non-target engine to ensure that only the class of the appointed engine is loaded.
Custom startup entry class in SpringBoot framework, default through JarLauncher class as startup entry for executable JAR. The custom startup entry class realizes accurate control over the class loading process by inheriting JarLauncher and rewriting its core method. Therefore, the custom start entry class inheritance JarLauncher and the rewriting createClassLoader method dynamically exclude dependent packets of non-target engines according to system parameters, and identify JAR packets of different engines through a predefined dependency mapping table to realize accurate filtering.
And pushing the content which completes the packaging project to a Maven private service after compiling, and providing for the subsequent project. And storing the compiled custom JAR package by a Maven warehouse server in the Maven private service enterprise. By pushing the packaging engineering to the private service, other items can directly refer to the package, so that the quick switching of the bottom-layer network engine is realized, and repeated compiling is not needed.
As shown in fig. 2, the technical scheme adopted by the present invention is described in the following specific embodiment, in which the service engineering needs to be switched to any one of the 2 network engines of tomcat/eastern common tongweb at any time to provide services to the outside, and the network engines are switched rapidly and flexibly in the deployment stage.
Step1, custom starting an entry class:
newly creating an engineering jar-laboratory, and then creating a class
public class MyJarLauncher extends JarLauncher {
Key function
public static void main(String[] args) throws Exception {
new MyJarLauncher().launch(args);
}
}
Step2, self-defining a Layout manager:
public class MyJarLayout extends Jar implements CustomLoaderLayout {
@Override
public void writeLoadedClasses(LoaderClassesWriter w) throws Exception {
Key/code
writer.writeLoaderClasses("META-INF/loader/jar-launch.jar");
}
Class of boot
@Override
public String getLauncherClassName() {
Return MyJarLauncher class paths;
}
}
The specific content of MyLayoutfactor.java is:
public class MyLayoutFactory extends DefaultLayoutFactory {
@Override
public Layout getLayout(File source) {
String lowerCaseFileName = source.getName().toLowerCase(Locale.ENGLISH);
if (lowerCaseFileName.endsWith(".jar")) {
return new MyJarLayout();
}
return super.getLayout(source);
}
}
Engineering compilation is pushed to a maven private service for subsequent use.
Step 3, business engineering uses a custom Layout manager:
The business objective in this step is to adjust the behavior of the maven package plug-in any business engineering that needs to switch the network engine quickly, specifically as follows:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<id>repackage</id>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<layoutFactory implementation="com.fingard.rdc.avatar.cd.MyLayoutFactory"/>
</configuration>
</execution>
</executions>
</plugin>
By using MyLayoutFactory class in the packing repackage stage, according to the above description, a custom layout implementation class MyJarLayout object is returned, which mainly implements the following 2 behaviors:
1) Writing the related class of jar-launch engineering into the final jar package
2) Modifying the name of a startup class
So far, the final executable package is executed from the user-defined startup class, and the startup class entry replacement is smoothly realized.
And 4, customizing a ClassLoader:
Based on the fact that in the embodiment, the business engineering needs to switch to any one of the 2 network engines of the tomcat/eastern communication tongweb at any time to provide services to the outside, the definition of the ClassLoader is explained to achieve the point.
Filter bag
private static final Map<String, String[]>APPLICATION_SERVER_DEPENDENCIES = new ConcurrentHashMap<String, String[]>();
static {
Dependence of// tomcat
APPLICATION_SERVER_DEPENDENCIES.put("tomcat", new String[] {
"tomcat-embed-core",
"tomcat-embed-el",
"tomcat-embed-websocket",
"spring-boot-starter-tomcat"
});
Dependence of/(eastern general tongweb)
APPLICATION_SERVER_DEPENDENCIES.put("tongweb",
new String[] {
"tongweb-dependencies-check",
"tongweb-embed-core",
"tongweb-embed-el",
});
}
@Override
protected ClassLoader createClassLoader(URL[] urls) throws Exception {
Dependency package for other network engines requiring exclusion according to network engine type- > statistics
String engine = System.getProperty("network.engine.type", "tomcat");
Set<String>excludedJarNamePrefixs = new HashSet<String>();
for (Entry<String, String[]>entry : APPLICATION_SERVER_DEPENDENCIES.entrySet()) {
if (!entry.getKey().equalsIgnoreCase(engine)) { excludedJarNamePrefixs.addAll(Arrays.asList(entry.getValue()));
}
}
List<URL>filteredUrlList = new ArrayList<>();
Current url/traversal
for (final URL url : urls) {
String path = url.getPath();
Name normalization
if (path.endsWith(".jar!/")) {
path = path.substring(0, path.length() - 2);
}
Direct reservation of/(non-jar)
if (!path.endsWith(".jar")) {
filteredUrlList.add(url);
continue;
}
The comparison is carried out according to the jar name
String jarName = path.substring(path.lastIndexOf('/') + 1);
if (excludedJarNamePrefixs.stream().noneMatch(jarName::startsWith)) {
Keep-on-demand
filteredUrlList.add(url);
} else {
I/need to discard
System.out.println ("discard- >" +url);
}
}
return super.createClassLoader(filteredUrlList.toArray(new URL[0]));
}
By specifying the type of network engine type in the start-up parameter, the other network engines can be excluded from being dependent on the packet, thereby realizing the switching of the underlying network engine.
The method is characterized in that a custom-starting entry class inheritance JarLauncher and a rewriting createClassLoader method are used, a pre-defined application_SERVER_ DEPENDENCIES dependence mapping table is combined, a dependence package of a non-target engine is dynamically filtered according to starting parameters, meanwhile, a custom-starting class is embedded into a JAR package and a MANIFAST.MF starting entry is modified in a packaging stage through a custom-starting Layout manager extension JarLayout, layout logic injection is realized by combining with Maven plug-in configuration, the type of the target engine is designated only through the starting parameters in deployment, a ClassLoader automatically traverses a URL array and filters conflict dependence according to dependence prefixes, so that seamless switching of multiple engines such as Tomcat, tongWeb is realized.
The following table shows the comparison of response times employed in the present invention versus the corresponding directions in the prior art:
it should be noted that, although the units are seconds, in the financial services industry, the effects of differing seconds are very dramatic.
In addition, the invention also comprises an electronic device, comprising:
a memory for storing a computer program;
And the processor is used for realizing a method for rapidly switching the program bottom layer network engine based on SpringBoot framework when executing the program stored on the memory.
The invention also includes a computer readable storage medium having a computer program stored therein, which when executed by a processor, implements a method for switching a program-based network engine rapidly based on SpringBoot framework.
While the application has been described in terms of preferred embodiments, it is not intended to limit the scope of the application. It is intended that all modifications within the scope of the application, i.e., all equivalents thereof, be embraced by the application as they come within their scope without departing from the application. In the description of the present specification, reference to the terms "one embodiment/manner," "some embodiments/manner," "example," "a particular example," "some examples," etc., means that a particular feature, structure, material, or characteristic described in connection with the embodiment/manner or example is included in at least one embodiment/manner or example of the application. In this specification, the schematic representations of the above terms are not necessarily for the same embodiment/manner or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments/modes or examples. Furthermore, the various embodiments/modes or examples described in this specification and the features of the various embodiments/modes or examples can be combined and combined by persons skilled in the art without contradiction.
Furthermore, the terms "first," "second," and the like, are used for descriptive purposes only and are not to be construed as indicating or implying a relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defining "a first" or "a second" may explicitly or implicitly include at least one such feature. In the description of the present application, the meaning of "plurality" means at least two, for example, two, three, etc., unless specifically defined otherwise.
It will be appreciated by those skilled in the art that the above-described embodiments are merely for clarity of illustration of the disclosure, and are not intended to limit the scope of the disclosure. Other variations or modifications will be apparent to persons skilled in the art from the foregoing disclosure, and such variations or modifications are intended to be within the scope of the present disclosure.

Claims (10)

1. The method for rapidly switching the program bottom layer network engine based on SpringBoot framework is characterized by comprising two separate projects, namely an operation project and a packaging project, wherein the operation project comprises a Layout realization class and a dynamic filtering rule engine, the packaging project comprises a built-in Layout factory and a class dynamic injection mechanism, the Layout factory packages business projects into customized classes through plug-ins based on official main class Layout, the packaging project is completed through custom starting of an entry class, custom Layout manager and custom ClassLoader, and rapid switching of the bottom layer network engine is completed through use of custom Layout manager.
2. The method for quickly switching program bottom layer network engine based on SpringBoot framework as set forth in claim 1, wherein the custom startup entry class inherits JarLauncher and rewrites createClassLoader method, dynamically eliminates dependent packets of non-target engines according to system parameters, and identifies JAR packets of different engines through a predefined dependency mapping table.
3. The method for quickly switching a program bottom layer network engine based on SpringBoot framework according to claim 2, wherein the content after the packaging engineering is compiled is pushed to Maven private service for subsequent engineering.
4. The method for quickly switching program bottom layer network engine based on SpringBoot framework according to claim 1, wherein custom Layout manager, extension JarLayout, embeds custom startup class into final JAR package in packing stage, ensures startup entry to point to custom logic, combines Maven plug-in configuration, covers default packing behavior, realizes Layout logic injection, carries out parameterized switching in deployment stage, specifies target engine by startup parameter, and automatically eliminates conflict dependence.
5. The method for quickly switching program bottom layer network engine based on SpringBoot framework according to claim 1, wherein defining filter packets is performed when customizing ClassLoader, specifically defining static application_server_ DEPENDENCIES in related classes, and configuring dependency packet lists of different network engines respectively.
6. The method for quickly switching program bottom layer network engine based on SpringBoot framework according to claim 1, wherein the method further needs to rewrite the method when customizing ClassLoader, specifically includes obtaining network engine type from a start parameter network.engine.type, counting a dependent packet prefix set excludedJarNamePrefixs of a non-designated network engine, traversing URL array, comparing jar packet name with prefix set, filtering out unnecessary URL, and finally calling parent class method to create ClassLoader by using the filtered URL array.
7. The method for a SpringBoot framework based fast handover procedure underlay network engine according to any one of claims 1-6, wherein the SpringBoot supported network engine includes at least two of Tomcat, jetty, undertow, netty.
8. The method of SpringBoot framework based fast handover procedure underlay network engine according to any one of claims 1-6, wherein the SpringBoot supported network engine further comprises TongWeb.
9. An electronic device, comprising:
a memory for storing a computer program;
A processor for implementing the method of any of claims 1-8 when executing a program stored on a memory.
10. A computer readable storage medium, characterized in that the computer readable storage medium has stored therein a computer program which, when executed by a processor, implements the method of any of claims 1-8.
CN202510928561.6A 2025-07-07 A method for quickly switching the underlying network engine of the program based on the SpringBoot framework Active CN120406920B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202510928561.6A CN120406920B (en) 2025-07-07 A method for quickly switching the underlying network engine of the program based on the SpringBoot framework

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202510928561.6A CN120406920B (en) 2025-07-07 A method for quickly switching the underlying network engine of the program based on the SpringBoot framework

Publications (2)

Publication Number Publication Date
CN120406920A true CN120406920A (en) 2025-08-01
CN120406920B CN120406920B (en) 2025-10-10

Family

ID=

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9098667B1 (en) * 2013-03-15 2015-08-04 Cadence Design Systems, Inc. Methods, systems, and articles of manufacture for implementing physical designs with force directed placement or floorplanning and layout decomposition
CN112363755A (en) * 2020-11-20 2021-02-12 成都秦川物联网科技股份有限公司 Low-coupling expansion business system based on plug-in engine injection
CN114416536A (en) * 2021-12-29 2022-04-29 江苏康众汽配有限公司 Integrated unit testing method and system based on SpringBoot
CN115712456A (en) * 2022-12-14 2023-02-24 中电万维信息技术有限责任公司 Dependence management and tool integration method based on springboot
CN117252006A (en) * 2023-09-18 2023-12-19 国家能源投资集团有限责任公司 Coupled data network cloud information management and control platform based on numerical physical simulation

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9098667B1 (en) * 2013-03-15 2015-08-04 Cadence Design Systems, Inc. Methods, systems, and articles of manufacture for implementing physical designs with force directed placement or floorplanning and layout decomposition
CN112363755A (en) * 2020-11-20 2021-02-12 成都秦川物联网科技股份有限公司 Low-coupling expansion business system based on plug-in engine injection
CN114416536A (en) * 2021-12-29 2022-04-29 江苏康众汽配有限公司 Integrated unit testing method and system based on SpringBoot
CN115712456A (en) * 2022-12-14 2023-02-24 中电万维信息技术有限责任公司 Dependence management and tool integration method based on springboot
CN117252006A (en) * 2023-09-18 2023-12-19 国家能源投资集团有限责任公司 Coupled data network cloud information management and control platform based on numerical physical simulation

Similar Documents

Publication Publication Date Title
US8799885B2 (en) Method and system for automated root-cause analysis for class loading failures in java
US7484223B2 (en) System and method for building a run-time image from components of a software program
US9477462B2 (en) System and method for software product versioning packaging, distribution, and patching
US9542175B2 (en) Continuous deployment
CN105657191B (en) Application increment upgrading method and system based on Android system
US9075596B2 (en) Deployment
US8112745B2 (en) Apparatus and method for capabilities verification and restriction of managed applications in an execution environment
US20080127054A1 (en) Connecting with an application instance
US7784043B2 (en) Method and system for automated code-source indexing in Java Virtual Machine environment
EP1437657A2 (en) System and method for management of software applications
US8099735B2 (en) Method and system for module initialization
EP2184904A1 (en) Method for automatically installing and configuring application and services on devices which comprise lifecycle management functionalities and corresponding client premises equipments, auto configuration server and module
US20080127053A1 (en) Controlling application features
US7934084B2 (en) Method and system for module initialization with an arbitrary number of phases
US20080127055A1 (en) Application proxy
US20070233717A1 (en) Generic product configuration framework for building product specific installers
CN119806552A (en) A method, device and system for locally deploying a cross-platform graph database program
CN116107590A (en) Implementation method and system for compatible micro-service and monomer architecture in software product development and deployment
CN120406920B (en) A method for quickly switching the underlying network engine of the program based on the SpringBoot framework
CN120406920A (en) A method for quickly switching the underlying network engine of the program based on the SpringBoot framework
Turner et al. Creating XPCOM Components
CN115629739A (en) Front-end system implementation method, device, equipment and storage medium
WO2023154092A1 (en) Dynamically overriding a function based on a capability set during load time
CN113821224A (en) Method, system, equipment and storage medium for replacing environment variable
CN118409786B (en) Method, device, equipment and medium for configuring dynamic link library based on multiple processes

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant