Project framework generation method, equipment and medium
By generating a standardized Spring Boot project framework in Java enterprise-level application development, the problem of difficult code standardization is solved, development efficiency and code consistency are improved, maintenance difficulty is reduced, and project quality and stability are improved.
Patent Information
- Application Number
- CN202510087111.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-20
- Publication Date
- 2025-05-13
AI Technical Summary
In Java enterprise-level application development, it is difficult to ensure code standardization in the early stages of project development, which increases the development difficulty and cost. Continuous integration tools can only conduct standardized inspections after the code is submitted, making it difficult to prevent the cost of later correction of errors.
Provide a project framework generation method. By creating Spring Boot projects, determining the functions to be implemented, and defining the function classes corresponding to each target to be optimized, writing a Controller to return to the processing class of the function class, realizing the unification of response format, exception processing and log processing, and generating a standardized project framework.
It significantly improves development efficiency, ensures the consistency and readability of code, reduces the difficulty of post-maintenance and upgrades, improves the overall quality and stability of the project, promotes team collaboration, and reduces code conflicts caused by different personal coding habits.
Smart Images

Figure CN119987736A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of software development technology, and in particular to a project framework generation method, device and medium. Background Art
[0002] Project standardization is regarded as a key link in improving R&D efficiency and code quality. It includes code style, project structure, configuration files, code templates and other aspects. It can not only improve the readability and maintainability of the code, but also reduce the repetitive writing of code, reduce the cost of code understanding and maintenance, and improve overall R&D efficiency.
[0003] Currently, in terms of code standards, although there are many methods and tools (such as code review, code scanning, etc.) to ensure the standardization of code, most of these methods have limitations. Manual intervention can guarantee code quality to a certain extent, but it is limited by individual subjectivity and experience differences, which can easily lead to inconsistent implementation of standards and even omissions of standards, affecting the overall quality and consistency of the project. On the other hand, continuous integration (CI) tools can usually only perform standard checks after the code is submitted, making it difficult to ensure standards in the early stages of project development, increasing the cost of correcting errors later.
[0004] For Java enterprise application development, the Spring Boot framework is popular for its rapid development capabilities. However, when using Spring Boot for project development, developers need to handle the standardization of the project by themselves, which increases the difficulty and cost of development. Summary of the invention
[0005] The embodiments of the present application provide a project framework generation method, device and medium to solve the above technical problems.
[0006] On the one hand, an embodiment of the present application provides a project framework generation method, comprising:
[0007] Create a Spring Boot project to determine multiple functions to be implemented required by the Spring Boot project, and determine the target functions to be optimized among the multiple functions to be implemented; wherein the target functions to be optimized include: response format, exception handling and log processing;
[0008] Define the function class corresponding to each target function to be optimized, and write the Controller to return to the processing class of the function class to unify the code blocks corresponding to the target function to be optimized and realize the standardized coding of the project;
[0009] Generate the corresponding project framework based on the unified code blocks after the project specification coding.
[0010] In one implementation of the present application, a function class corresponding to each target function to be optimized is defined, and a Controller is written to be returned to the processing class of the function class, specifically including:
[0011] In the case where the target function to be optimized is in a response format, a public function class is defined, and a private field code is defined in the function class to store a response status code; wherein the response status code is used to indicate whether the processing result of the request is in a success state or a failure state;
[0012] A private field msg is defined in the function class to store a response message, and a private field data is defined in the function class to store response data; wherein the response message is used to represent a message or description related to the response status code.
[0013] In one implementation of the present application, the code blocks corresponding to the target functions to be optimized are unified to achieve project standardization and coding, specifically including:
[0014] In the case where the target function to be optimized is in response format, the request to be processed is received through the Controller, and the corresponding entity object is returned;
[0015] Send the entity object to the unified response processor, and through the unified response processor, package the entity object into the private field data;
[0016] The response result of the function to be optimized corresponding to the request to be processed is output, and when the response result matches the preset coding specification, the response result is returned to the front-end processor to achieve the unification of the response format.
[0017] In one implementation of the present application, the code blocks corresponding to the target functions to be optimized are unified to achieve project standardization and coding, specifically including:
[0018] In the case where the target function to be optimized is exception processing, receiving a request to be processed through a Controller, and sending the request to be processed to a unified exception handler;
[0019] Determining, by means of the unified exception handler, whether there is an exception in the target function to be optimized corresponding to the request to be processed;
[0020] In the case where the target function to be optimized has an exception, a first status code is returned, and the exception type corresponding to the target function to be optimized is determined; wherein the first status code is used to indicate that the request to be optimized is in an exception processing state, and the exception type includes parameter verification exception and service exception;
[0021] When the exception type is a parameter verification exception, a second status code is returned, and when the exception type is a service exception, a third status code is returned to achieve unified exception handling; wherein, the second status code and the third status code are respectively used to indicate that the request to be optimized is a parameter verification exception and a service exception.
[0022] In one implementation of the present application, the code blocks corresponding to the target functions to be optimized are unified to achieve project standardization and coding, specifically including:
[0023] In the case where the target function to be optimized is log processing, the request to be processed by the front-end processor is sent to the unified log processor, and the corresponding request log is recorded by the unified log processor;
[0024] Send the pending request to the Controller for request processing to obtain corresponding log response data, and send the log response data to the unified log processor;
[0025] The unified log processor records the response log corresponding to the log response data, and returns the log response data to the front-end processor, thereby achieving unified log processing.
[0026] In one implementation of the present application, a Spring Boot project is created to determine multiple functions to be implemented required by the Spring Boot project, specifically including:
[0027] Create a Spring Boot project through Spring Boot Initializr, and determine the functions to be implemented in the Spring Boot project and the dependency information required for the functions to be implemented to generate a project structure;
[0028] Select the dependency information required for the function to be implemented in the IDE, and configure the basic information corresponding to the Spring Boot project to obtain the corresponding configuration file; wherein the basic information includes: port number and database connection.
[0029] In one implementation of the present application, before generating a corresponding project framework based on a unified code block coded according to the project specification, the method includes:
[0030] Integrate dependency information and basic information into IDE for development;
[0031] Through the API interface of Spring Boot Initializr, the unified code blocks of the project are deployed to the server.
[0032] In one implementation of the present application, a corresponding project framework is generated based on a unified code block after the project specification is coded, specifically including:
[0033] Receive changes to the service address in Spring Boot Initializr through the IDE;
[0034] Based on the modification trigger, the unified code block after the project specification coding is executed, and the corresponding target function to be optimized is written in combination with the dependency information and the basic information to generate the corresponding project framework.
[0035] On the other hand, an embodiment of the present application further provides a project framework generation device, the device comprising:
[0036] at least one processor;
[0037] and, a memory communicatively coupled to the at least one processor;
[0038] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute a project framework generation method as described above.
[0039] On the other hand, an embodiment of the present application further provides a non-volatile computer storage medium storing computer executable instructions, which, when executed, implement a project framework generation method as described above.
[0040] The present application embodiment provides a project framework generation method, device and medium, including at least the following
[0041] Beneficial effects:
[0042] By quickly creating a Spring Boot project and uniformly processing common functions to be optimized in the project (such as response format, exception handling, and log processing), developers can avoid repeatedly writing code for these functions in each project, thereby significantly improving development efficiency; by defining the function class corresponding to each target function to be optimized and centrally writing the processing logic returned by the Controller in these function classes, the project is standardized and coded, which helps to ensure the consistency and readability of the code and reduces the difficulty of subsequent maintenance and upgrades; by uniformly processing key functions such as response format, exception handling, and log processing, it helps to improve the overall quality and stability of the project; by generating a unified project framework, a common development foundation is provided, which helps to promote team collaboration and reduce code conflicts caused by different personal coding habits. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0044] Figure 1 A schematic diagram of a process flow of a project framework generation method provided in an embodiment of the present application;
[0045] Figure 2 A schematic diagram of the internal structure of a project framework generation device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0046] In order to make the purpose, technical solution and advantages of the present application clearer, the technical solution of the present application will be clearly and completely described below in combination with the specific embodiments of the present application and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.
[0047] The technical solutions provided by various embodiments of the present application are described in detail below in conjunction with the accompanying drawings.
[0048] Figure 1 A flowchart of a project framework generation method provided in an embodiment of the present application.
[0049] The analysis method involved in the embodiments of the present application can be implemented by a terminal device or a server, and the present application does not impose any special restrictions on this. For the convenience of understanding and description, the following embodiments are described in detail by taking a server as an example.
[0050] It should be noted that the server may be a single device or a system consisting of multiple devices, that is, a distributed server, and this application does not make any specific limitation on this.
[0051] like Figure 1 As shown, a project framework generation method provided in an embodiment of the present application includes:
[0052] 101. Create a Spring Boot project to determine multiple functions to be implemented in the Spring Boot project, and identify the target functions to be optimized among the multiple functions to be implemented.
[0053] It should be noted that the target functions to be optimized in the embodiments of the present application include: response format, exception handling and log processing.
[0054] Specifically, in one embodiment of the present application, a Spring Boot project is created to determine multiple functions to be implemented required by the Spring Boot project, specifically including:
[0055] Create a Spring Boot project through Spring Boot Initializr, and determine the functions to be implemented in the Spring Boot project and the dependency information required for the functions to be implemented to generate the project structure;
[0056] In the IDE, select the dependency information required for the function to be implemented, and configure the basic information corresponding to the Spring Boot project to obtain the corresponding configuration file; the basic information includes: port number and database connection.
[0057] In one embodiment, according to project requirements and personal preferences, select "Maven Project" or "Gradle Project", select Java as the language, select the required Spring Boot version, and then fill in the basic information of the project, such as Group (the path after the organization or company domain name is reversed), Artifact (project name), Name (project display name), Description (project description), Package Name (package name, usually automatically generated), Packaging (packaging method, the default is "Jar"), and Java (that is, select the Java version).
[0058] Select the dependencies required for the functions to be implemented according to the project requirements. For example, if the project needs to process Web requests, select "Spring Web"; if you need to connect to a database, select "Spring Data JPA" and the corresponding database driver (such as "H2 Database" or "MySQL Driver", etc.). In addition, you can also select other dependencies as needed, such as "SpringSecurity" for security authentication, "Spring Boot DevTools" for development and debugging, etc.
[0059] After that, Spring Boot Initializr generates a project structure containing the selected dependencies and packages it into a ZIP file for download. After downloading and unzipping the ZIP file, import the project into an IDE (such as IntelliJ IDEA, Eclipse, etc.). The IDE usually automatically recognizes and configures the Maven or Gradle project structure.
[0060] In the src / main / resources / application.properties or application.yml configuration file, add or modify the server.port property to set the port number where the application runs. For example, server.port = 8081. Also in the application.properties or application.yml configuration file, add the database connection information. For example, for a MySQL database, you can add the following configuration.
[0061] 102. Define the function class corresponding to each target function to be optimized, and write the Controller to return to the processing class of the function class to unify the code blocks corresponding to the target function to be optimized and realize the standardized coding of the project.
[0062] Specifically, in one embodiment of the present application, a function class corresponding to each target function to be optimized is defined, and a Controller is written to be returned to the processing class of the function class, specifically including:
[0063] When the target function to be optimized is in response format, define a public function class, and define a private field code in the function class to store the response status code; the response status code is used to indicate whether the processing result of the request is in a success state or a failure state;
[0064] A private field msg is defined in the function class to store a response message, and a private field data is defined in the function class to store response data; wherein the response message is used to represent a message or description related to a response status code.
[0065] In one embodiment, a generic Java class named StandardResponse is defined, using two annotations from the Lombok library: @Data and @Builder. This class is intended to be a general response data structure that can carry a status code (code), a message (msg), and data of any type (data). First, a public class StandardResponse is defined that accepts a generic parameter T. This means that the data field can be of any type, and the specific type is specified when using the StandardResponse class.
[0066] Define a private field code to store the response status code. Status codes are usually used to indicate the processing results of a request, such as different states of success or failure. For example, 200 can be used to indicate success, 4xx to indicate a client error, and 5xx to indicate a server error. Define a private field msg to store messages or descriptions related to the response status code. This field will provide more information about the request processing results, which may be more detailed error information or confirmation information of successful operation, to help the caller understand the meaning of the status code. Define a private field data to store response data. This field will contain the actual data after the request is processed, such as query results, updated objects, etc. If the request processing fails, this field can be null or contain error information.
[0067] In one embodiment of the present application, the code blocks corresponding to the target functions to be optimized are unified to achieve project standardization and coding, which specifically includes:
[0068] When the target function to be optimized is in response format, the request to be processed is received through the Controller, and the corresponding entity object is returned;
[0069] Send the entity object to the unified response processor, and wrap the entity object into the private field data through the unified response processor;
[0070] Output the response result of the function to be optimized corresponding to the pending request, and return the response result to the front-end processor when the response result matches the preset encoding specification to achieve a unified response format.
[0071] In one embodiment, in the Controller layer of the Spring Boot project, an interface method for receiving requests to be processed is defined. The method receives request parameters, executes corresponding business logic, and returns an entity object as the processing result. It should be noted that in actual applications, the Controller layer usually calls the Service layer to execute business logic and returns the entity object returned by the Service layer. Create a unified response processor class, which is responsible for packaging the entity object returned by the Controller layer into the response body and adding necessary response information (such as status code, message, etc.). It should be noted that in actual applications, the unified response processor may dynamically set the status code and message according to the business logic.
[0072] Modify the method of the Controller layer so that it does not directly return the entity object, but calls the unified response processor to build and return the response entity. Since directly modifying the method of the Controller layer may involve a lot of code changes, here is a way to indirectly implement it through AOP (aspect-oriented programming) or filters. In actual applications, if AOP or filters are used, there is no need to modify the method body of the Controller layer. You only need to add the corresponding aspect logic or filter logic before and after the method execution.
[0073] The front-end processor (such as the front-end controller, AJAX request processor, etc.) receives the response entity returned by the Spring Boot backend and performs corresponding processing according to the code, msg, and data fields in the response body. For example, if the code is 200, a success message is displayed and the data in the data field is parsed; if the code is a non-200 value, an error message is displayed and the corresponding error handling logic is executed as needed.
[0074] In actual applications, it may be necessary to preset a set of encoding specifications to ensure the uniformity and consistency of the response format. For example, the scope and meaning of the status code, the format and content of the message, the structure and type of the data, etc. can be specified. In the unified response processor, the response entity can be constructed according to these preset encoding specifications, and corresponding verification and processing can be performed in the Controller layer or front-end processor.
[0075] In one embodiment of the present application, the code blocks corresponding to the target functions to be optimized are unified to achieve project standardization and coding, which specifically includes:
[0076] When the target function to be optimized is exception handling, the request to be processed is received through the Controller and sent to the unified exception handler;
[0077] Through a unified exception handler, determine whether there is an exception in the target function to be optimized corresponding to the pending request;
[0078] When an exception occurs in the target function to be optimized, a first status code is returned, and the exception type corresponding to the target function to be optimized is determined; wherein the first status code is used to indicate that the request to be optimized is in an exception processing state, and the exception types include parameter verification exception and service exception;
[0079] When the exception type is a parameter verification exception, the second status code is returned, and when the exception type is a service exception, the third status code is returned to achieve unified exception handling; wherein, the second status code and the third status code are respectively used to indicate that the request to be optimized is a parameter verification exception and a service exception.
[0080] In one embodiment, in the Controller layer of the Spring Boot project, an interface method for receiving requests to be processed is defined. The method receives request parameters and sends them to a unified exception handler for processing. In practical applications, all exceptions are usually not captured and handled directly in the Controller layer, but are handled globally through Spring's @ControllerAdvice and @ExceptionHandler annotations. Create a unified exception handler class that is responsible for receiving exceptions thrown by the Controller layer, determining the exception type, and returning the corresponding status code and error information.
[0081] In the unified exception handler, the corresponding status code and error message are returned according to the captured exception type. For example, for parameter verification exceptions, the 400 status code and the "Invalid request parameters" error message are returned; for service exceptions, the 500 status code and the "Internal server error" error message are returned. For other unknown exceptions, the 500 status code and a general error message can also be returned.
[0082] The front-end processor receives the exception response entity returned by the Spring Boot backend and performs corresponding processing according to the code and message fields in the response body. For example, if the code is 400, the parameter verification error message is displayed; if the code is 500, the server internal error message is displayed, and the corresponding error handling logic (such as retrying the request, displaying the error page, etc.) is executed as needed.
[0083] In one embodiment of the present application, the code blocks corresponding to the target functions to be optimized are unified to achieve project standardization and coding, which specifically includes:
[0084] When the target function to be optimized is log processing, the pending request of the front-end processor is sent to the unified log processor, and the corresponding request log is recorded by the unified log processor;
[0085] Send the pending request to the Controller for request processing to obtain the corresponding log response data, and send the log response data to the unified log processor;
[0086] The response log corresponding to the log response data is recorded by the unified log processor, and the log response data is returned to the front-end processor to achieve unified log processing.
[0087] In one embodiment, after receiving the user's request, the front-end processor sends the request to the unified log processor. At this time, the unified log processor records the basic information of the request, such as the receiving time, request type, and request parameters, as a request log. After receiving the pending request from the front-end processor, the unified log processor first records the log information of the request. The log information may include the timestamp of the request, the URL path of the request, the request method (GET / POST, etc.), the request parameters, the user information (such as user ID, user name, etc., if available), etc. This information can be recorded in a log file in text form or JSON format, etc., or stored in a log database.
[0088] After recording the request log, the unified log processor forwards the pending request to the corresponding Controller for business logic processing. The Controller performs corresponding operations based on the type and parameters of the request and generates log response data. After the Controller processes the request, it returns the generated log response data to the unified log processor. At this time, the unified log processor records the log information again, but this time it records the response log. The response log may include the timestamp of the response, the response status code, the response data, etc. After the unified log processor receives the log response data returned by the Controller, it records the log information of the response. Then, the log response data is returned to the front-end processor. The front-end processor can perform corresponding processing based on the response data, such as updating the user interface, displaying the processing results, etc.
[0089] In this way, both request logs and response logs are recorded and managed through the unified log processor, which helps to simplify the log processing process and improve the readability and maintainability of the log. At the same time, the unified log processor can also provide functions such as log query and log analysis, which makes it easier for developers to monitor and analyze the system operation status.
[0090] In practical applications, the unified log processor may need to interact with the log storage system (such as log files, log databases, etc.) to achieve persistent storage and query of logs. In order to improve the performance and scalability of log processing, you can consider using an asynchronous log processing mechanism to separate the logging operation from the business logic processing operation. When logging, you should pay attention to protecting user privacy and sensitive information to avoid leaking sensitive information into the log.
[0091] 103. Generate the corresponding project framework based on the unified code blocks after the project specification coding.
[0092] Specifically, in one embodiment of the present application, before generating a corresponding project framework based on a unified code block coded according to the project specification, the following steps are included:
[0093] Integrate dependency information and basic information into IDE for development;
[0094] Through the API interface of Spring Boot Initializr, the unified code blocks of the project are deployed to the server.
[0095] In one embodiment, first, use Spring Boot Initializr to generate a project structure and download the generated ZIP file. Then, import the project in an IDE (such as IntelliJ IDEA, Eclipse, etc.). The IDE will automatically recognize and configure the Maven or Gradle project structure. In the project structure of the IDE, check and confirm that the required dependency information is already included in the file. This dependency information is selected when the Spring Boot Initializr generates the project. Open the configuration file in the IDE and configure the basic information of the project according to actual needs, such as server port number, database connection information, log level, etc.
[0096] Visit the official website or related documents of Spring Boot Initializr to learn how to use the API interface and parameter descriptions. In the IDE, use the packaging command of Maven or Gradle to generate a deployable package for the project. Then, write a script or use a tool to call the API interface of Spring Boot Initializr to upload the generated deployable package to the server. The API interface usually requires relevant information of the project (such as project name, version, dependencies, etc.) and the file path of the deployment package. After the deployment is complete, verify whether the project runs successfully by accessing the specified port of the server or using related commands. At the same time, you can check the log files or monitoring tools to confirm whether the project works as expected.
[0097] In one embodiment of the present application, a corresponding project framework is generated based on a unified code block after the project specification is coded, specifically including:
[0098] Receive changes to the service address in Spring Boot Initializr through the IDE;
[0099] Based on the modification trigger, the unified code block after the project specification coding is executed, and the corresponding target function to be optimized is written in combination with the dependency information and basic information to generate the corresponding project framework.
[0100] In one embodiment, a Spring Boot related plug-in is installed in the IDE to better support the development of Spring Boot projects, and the IDE is configured to use Spring Boot Initializr as a project creation template. When creating a new Spring Boot project in the IDE, or modifying a configuration file in an existing project, the user can enter or modify the service address of Spring Boot Initializr in the IDE's configuration interface or configuration file. Afterwards, the IDE will receive this modification and apply it to the process of project creation or configuration update.
[0101] When the service address is modified, the IDE will trigger an internal mechanism that calls the Spring Boot Initializr API or uses the modified service address to generate a unified code block for the project specification. This process may involve sending an HTTP request to the Spring Boot Initializr service endpoint, which contains the project metadata (such as dependency information, basic information, etc.) and possible service address parameters.
[0102] After receiving the unified code blocks, the IDE will parse the codes and generate the basic framework of the project based on the project's dependency information and basic information (such as port number, database connection, etc.). Next, the IDE will provide an interface or wizard that allows users to select or specify target functions to be optimized. These functions may be performance optimization, security enhancement, code refactoring, etc. Based on the user's selection, the IDE will automatically or semi-automatically write code snippets related to these target functions to be optimized and integrate them into the project framework.
[0103] Finally, the IDE will generate a complete SpringBoot project containing a basic framework and target function code snippets to be optimized. Users can continue to develop, test, and optimize this project in the IDE to ensure that it meets all business requirements and quality standards.
[0104] This application implements the Spring Boot Initializr API, packages it and deploys it on the company's internal server, and provides services in the form of HTTP Server. Users only need to modify the Server URL of Spring Boot Initializr in the IDE to the address of the service. It should be noted that the user in this application can be a developer.
[0105] The above is an embodiment of the method proposed in this application. Based on the same inventive concept, this application embodiment also provides a project framework generation device, whose structure is as follows: Figure 2 shown.
[0106] Figure 2 This is a schematic diagram of the internal structure of a project framework generation device provided in an embodiment of the present application. Figure 2 As shown, the device includes:
[0107] at least one processor;
[0108] and, a memory communicatively coupled to the at least one processor;
[0109] The memory stores instructions that can be executed by at least one processor, and the instructions are executed by at least one processor to enable the at least one processor to:
[0110] Create a Spring Boot project to determine multiple functions to be implemented in the Spring Boot project, and identify the target functions to be optimized among the multiple functions to be implemented; the target functions to be optimized include: response format, exception handling, and log processing;
[0111] Define the function class corresponding to each target function to be optimized, and write the Controller to return to the processing class of the function class to unify the code blocks corresponding to the target function to be optimized and realize the standardized coding of the project;
[0112] Generate the corresponding project framework based on the unified code blocks after the project specification coding.
[0113] The present application also provides a non-volatile computer storage medium storing computer executable instructions. When the computer executable instructions are executed, they can:
[0114] Create a Spring Boot project to determine multiple functions to be implemented in the Spring Boot project, and identify the target functions to be optimized among the multiple functions to be implemented; the target functions to be optimized include: response format, exception handling, and log processing;
[0115] Define the function class corresponding to each target function to be optimized, and write the Controller to return to the processing class of the function class to unify the code blocks corresponding to the target function to be optimized and realize the standardized coding of the project;
[0116] Generate the corresponding project framework based on the unified code blocks after the project specification coding.
[0117] Each embodiment in this application is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device and medium embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.
[0118] The above describes specific embodiments of the present application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0119] The devices and media provided in the embodiments of the present application correspond one-to-one to the methods. Therefore, the devices and media also have similar beneficial technical effects as the corresponding methods. Since the beneficial technical effects of the methods have been described in detail above, the beneficial technical effects of the devices and media will not be repeated here.
[0120] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0121] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0122] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0123] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0124] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0125] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0126] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0127] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity 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, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0128] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.
Claims
1. A project framework generation method, characterized in that: The method comprises: Create a Spring Boot project to determine multiple functions to be implemented required by the Spring Boot project, and determine the target functions to be optimized among the multiple functions to be implemented; wherein the target functions to be optimized include: response format, exception handling and log processing; Define the function class corresponding to each target function to be optimized, and write the Controller to return to the processing class of the function class to unify the code blocks corresponding to the target function to be optimized and realize the standardized coding of the project; Generate the corresponding project framework based on the unified code blocks after the project specification coding.
2. A project framework generation method according to claim 1, characterized in that: Define the function class corresponding to each target function to be optimized, and write the Controller to return to the processing class of the function class, including: In the case where the target function to be optimized is in a response format, a public function class is defined, and a private field code is defined in the function class to store a response status code; wherein the response status code is used to indicate whether the processing result of the request is in a success state or a failure state; A private field msg is defined in the function class to store a response message, and a private field data is defined in the function class to store response data; wherein the response message is used to represent a message or description related to the response status code.
3. A project framework generation method according to claim 1, characterized in that: Unify the code blocks corresponding to the target functions to be optimized to achieve standardized coding of the project, including: In the case where the target function to be optimized is in response format, the request to be processed is received through the Controller, and the corresponding entity object is returned; Send the entity object to the unified response processor, and through the unified response processor, package the entity object into the private field data; The response result of the function to be optimized corresponding to the request to be processed is output, and when the response result matches the preset coding specification, the response result is returned to the front-end processor to achieve the unification of the response format.
4. A project framework generation method according to claim 1, characterized in that: Unify the code blocks corresponding to the target functions to be optimized to achieve standardized coding of the project, including: In the case where the target function to be optimized is exception processing, receiving a request to be processed through a Controller, and sending the request to be processed to a unified exception handler; Determining, by means of the unified exception handler, whether there is an exception in the target function to be optimized corresponding to the request to be processed; In the case where the target function to be optimized has an exception, a first status code is returned, and the exception type corresponding to the target function to be optimized is determined; wherein the first status code is used to indicate that the request to be optimized is in an exception processing state, and the exception type includes parameter verification exception and service exception; When the exception type is a parameter verification exception, a second status code is returned, and when the exception type is a service exception, a third status code is returned to achieve unified exception handling; wherein, the second status code and the third status code are respectively used to indicate that the request to be optimized is a parameter verification exception and a service exception.
5. A project framework generation method according to claim 1, characterized in that: Unify the code blocks corresponding to the target functions to be optimized to achieve standardized coding of the project, including: In the case where the target function to be optimized is log processing, the request to be processed by the front-end processor is sent to the unified log processor, and the corresponding request log is recorded by the unified log processor; Send the pending request to the Controller for request processing to obtain corresponding log response data, and send the log response data to the unified log processor; The unified log processor records the response log corresponding to the log response data, and returns the log response data to the front-end processor, thereby achieving unified log processing.
6. A project framework generation method according to claim 1, characterized in that: Create a Spring Boot project to determine the multiple functions to be implemented required by the Spring Boot project, including: Create a Spring Boot project through Spring Boot Initializr, and determine the functions to be implemented in the Spring Boot project and the dependency information required for the functions to be implemented to generate a project structure; Select the dependency information required for the function to be implemented in the IDE, and configure the basic information corresponding to the Spring Boot project to obtain the corresponding configuration file; wherein the basic information includes: port number and database connection.
7. A project framework generation method according to claim 6, characterized in that: Before generating a corresponding project framework based on the unified code block after the project specification is coded, the method includes: Integrate dependency information and basic information into IDE for development; Through the API interface of Spring Boot Initializr, the unified code blocks of the project are deployed to the server.
8. A project framework generation method according to claim 7, characterized in that: Generate the corresponding project framework based on the unified code block after the project specification is coded, including: Receive changes to the service address in Spring Boot Initializr through the IDE; Based on the modification trigger, the unified code block after the project specification coding is executed, and the corresponding target function to be optimized is written in combination with the dependency information and the basic information to generate the corresponding project framework.
9. A project framework generation device, characterized in that: The device comprises: at least one processor; and, a memory communicatively coupled to the at least one processor; The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute a project framework generation method as described in any one of claims 1-8.
10. A non-volatile computer storage medium storing computer executable instructions, characterized in that: When the computer executable instructions are executed, a project framework generation method as described in any one of claims 1 to 8 is implemented.