WO2025007532A1 - 一种可定制化Java工程初始化方法及系统 - Google Patents
一种可定制化Java工程初始化方法及系统 Download PDFInfo
- Publication number
- WO2025007532A1 WO2025007532A1 PCT/CN2023/142715 CN2023142715W WO2025007532A1 WO 2025007532 A1 WO2025007532 A1 WO 2025007532A1 CN 2023142715 W CN2023142715 W CN 2023142715W WO 2025007532 A1 WO2025007532 A1 WO 2025007532A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- project
- maven
- module
- skeleton
- creation
- 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.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/20—Software design
- G06F8/24—Object-oriented
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/30—Creation or generation of source code
- G06F8/36—Software reuse
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/60—Software deployment
- G06F8/61—Installation
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/70—Software maintenance or management
- G06F8/71—Version control; Configuration management
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/10—Protocols in which an application is distributed across nodes in the network
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/34—Network arrangements or protocols for supporting network services or applications involving the movement of software or configuration parameters
Definitions
- the present invention belongs to the field of computer technology, and in particular relates to a customizable Java project initialization method and system.
- the back-end development of software engineering usually requires the creation of Java engineering projects, which is the initialization of code engineering.
- the SpringBoot framework is the mainstream development framework for Java backends, which contains a large number of practical development components. These development components are managed by Maven in the form of dependencies, and are imported into the project to provide corresponding capabilities for the project.
- the initialization of the project is a step that all developers cannot bypass when developing new components and new applications.
- the time spent on project initialization and the form of the project after initialization directly affect the overall project development progress.
- developers have the following pain points in the project initialization stage:
- the generated project lacks sufficient customizability, and many code segments need to be manually supplemented by developers at a later stage, which greatly prolongs the development time.
- the purpose of the present invention is to provide a customizable Java project initialization method and system to solve the deficiencies in the prior art. It proposes the concept of a template project generation service for the first time, which can quickly initialize the SpringBoot project and greatly improve the project creation efficiency of developers and reduce the dependency maintenance cost by importing relevant dependencies, resolving dependency conflicts, and generating various usage instructions.
- the front-end service module sends a creation request for creating a project to the back-end service module, and the back-end service module calls the Maven process module to read the meta-data.xml file in the skeleton project module;
- the Maven process module After obtaining the project creation rules by reading the meta-data.xml file in the skeleton project module, the Maven process module completes the creation of a customized Maven project and generates a template project;
- the Maven process module generates a customized Maven project to a fixed path, and the fixed path is from the Maven process module to the backend service module.
- the backend service module compresses and packages the customized Maven project and sends it to the user module.
- the steps of completing the creation of a customized Maven project by the Maven process module include:
- the backend service module calls the Maven process module to execute the archetype:generate instruction
- the Maven process module pulls the skeleton project with the corresponding name in the local computer and finds the archetype-metadata.xml file under the specific path of the skeleton project.
- the generation configuration of the creation project is obtained, and the Maven process module starts to execute the task of creating the project.
- the Maven process module starts executing the task of creating the project and further includes reading a skeleton velocity template file in a skeleton engineering module and rendering a customized code engineering file.
- read the skeleton velocity template file in the skeleton project module and render a customized code project file including:
- the existing code files are deleted according to the input parameters, and the template files corresponding to the unnecessary code files are deleted.
- the skeleton engineering module includes several groups, and the template engineering provides basic usage examples of the imported capabilities.
- the method further includes building a template generation service, and the specific steps are as follows:
- Another embodiment of the present application provides a customizable Java project initialization system, the system comprising:
- a front-end service module which is used to pass creation parameters to the back-end service module and compress the customized Maven project and return it to the user module;
- a backend service module is used to receive a creation request from the frontend service module to create a project and call a Maven process module to execute a computer instruction;
- the Maven process module is used to read files in the skeleton project to obtain creation rules
- a skeleton engineering module wherein the skeleton engineering module is used to create a project framework by creating parameters.
- Yet another embodiment of the present application provides a storage medium, wherein the storage medium stores a computer program, wherein the computer program is configured to implement any of the above methods when executed.
- Yet another embodiment of the present application provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to implement any of the above methods.
- the Java project initialization method proposed in this paper provides fine-grained integration of engineering capabilities: not only can the package name and project name be customized, but also the engineering capabilities can be customized and integrated (currently all based on Spring Boot, and other frameworks can be supported in the future); the template automatically imports dependencies and integrates capabilities: eliminating the trouble of manually adding dependencies and necessary configuration items, eliminating the need to resolve version conflicts between dependencies, reducing the developer's maintenance time on pom files, and focusing on business development; the template can provide basic sample code and documentation: providing basic usage examples of the imported capabilities, with usage instructions and official website document links in the Readme, etc., reducing the developer's time for searching for usage and self-testing, and improving development efficiency; more suitable for microservice application construction: for the construction of microservice applications, more practical options are provided, which is more suitable for integration with microservice platform-related products.
- the application hosting-related products of the PAAS platform currently lack a first-link function that can quickly generate applications in the entire life cycle process management of application development, deployment, monitoring, and operation and maintenance.
- the project initialization method proposed in this paper can supplement this link capability and improve the industry competitiveness of related products.
- FIG1 is a block diagram of a customizable Java project initialization system provided by an embodiment of the present invention.
- FIG2 is a schematic diagram of a process of a customizable Java project initialization method provided by an embodiment of the present invention
- FIG. 3 is a diagram showing an example of a code structure of a template engineering service skeleton engineering generated according to an embodiment of the present invention
- FIG. 4 is a diagram showing an example of a Java project code structure generated using a customizable Java project initialization method provided in an embodiment of the present invention.
- the embodiment of the present invention first provides a customizable Java project initialization method, which can be applied to electronic devices such as computer terminals, specifically ordinary computers, quantum computers, etc.
- FIG. 2 is a flow chart of a customizable Java project initialization method provided by an embodiment of the present invention, which may include the following steps:
- S1 obtaining a creation request for creating a project from a front-end user through a front-end service module, wherein the creation request for creating a project is created by the front-end user inputting page parameters and clicking Create;
- the front-end service module sends a request to create a project to the back-end service module, and the back-end service module calls the Maven process module to read the meta-data.xml file in the skeleton project module;
- the Maven process module After obtaining the project creation rules by reading the meta-data.xml file in the skeleton project module, the Maven process module completes the creation of a customized Maven project and generates a template project;
- the Maven process module generates a customized Maven project to a fixed path, where the fixed path is from the Maven process module to the backend service module.
- the backend service module compresses and packages the customized Maven project and sends it to the user module.
- the template project generation service provides users with a friendly project generation and customization interface.
- the front-end user clicks the create button the project creation request is issued, and the back-end calls the Maven process to execute mvn Archetype:generate instruction, the Maven process pulls the corresponding skeleton project from the local, obtains the creation rules by reading the meta-data.xml file in the skeleton project, completes the creation of the customized project, and the backend compresses the project and returns it to the user for download and use.
- the Maven process receives the archetype:generate instruction
- the Maven process pulls the skeleton project with the corresponding name in the local computer, finds the archetype-metadata.xml file in the specific path of the skeleton project, and obtains the project generation configuration;
- the Mavan process starts to execute the project creation task, reads the skeleton velocity template file in the skeleton project, and renders a customized code project file.
- the Mavan process starts executing the project creation task, reads the skeleton velocity template file in the skeleton project, and renders a customized code project file, including:
- Step 1 Build the front-end service to provide users with a friendly project creation and option display interface.
- the final interface effect is shown in Figure 2.
- Step 2 Build the backend service, receive the frontend creation request, parse the user customized parameter items, and immediately call the Maven process to execute the mvn archetype:generate instruction with parameters.
- the final assembly instruction class is as follows:
- Step 3 Develop the Maven archetype skeleton project, which mainly involves receiving and processing customized parameters, designing the project structure, writing velocity template files, and generating tests. After the skeleton project is developed, use the mvn install command to install it to the local Maven repository.
- the developed skeleton project code structure class is shown in Figure 3.
- FIG. 4 An example of the directory structure of a generated Java project is shown in Figure 4.
- the project is generated to include MySQL capabilities and Nacos registry center capabilities. MySQL-related code will be generated in the dao package of the java directory in Figure 4, Spring-related dependencies will be automatically imported (pom file is rewritten), and related configurations will be written to the application.yml file, as shown in Figure 5.
- FIG1 is a module diagram of a customizable Java project initialization system.
- the system includes:
- a front-end service module which is used to pass creation parameters to the back-end service module and compress the customized Maven project and return it to the user module;
- a backend service module is used to receive a creation request from the frontend service module to create a project and call a Maven process module to execute a computer instruction;
- the Maven process module is used to read files in the skeleton project to obtain creation rules
- a skeleton engineering module wherein the skeleton engineering module is used to create a project framework by creating parameters.
- the Maven process module obtains the Jar package through coordinates.
- the coordinates are composed of: company/organization (groupId) + project name (artifactId) + version (version).
- groupId company/organization
- artifactId project name
- version version
- the Jar package can be obtained from various warehouse sources such as the Internet and local.
- the backend service module After the backend service module completes the project creation, it needs to import the required jar, which needs to be imported through [coordinates].
- Maven will automatically load the corresponding dependencies. Deleting the coordinates will remove the dependencies.
- the jar package will not be imported into the project directory, but the Maven process module helps to associate it. However, the corresponding dependencies will be carried when packaging and deploying the project. If dependency A is imported, and A depends on B, B will be automatically loaded.
- the present invention can not only customize the package name and project name, but also customize and integrate the engineering capabilities; and the template automatically imports dependencies and integrates capabilities: eliminating the trouble of manually adding dependencies and necessary configuration items, eliminating the need to resolve version conflicts between dependencies, reducing the developer's maintenance time on the pom file, and focusing on business development.
- the template in the present invention can provide basic sample code and documentation: providing basic usage examples of the imported capabilities, with usage instructions and official website document links in the Readme, etc., reducing the developer's time searching for usage and self-testing, and improving development efficiency.
- the present invention is more suitable for building microservice applications: for the construction of microservice applications, it provides more practical options, and is more suitable for integration with microservice platform-related products.
- the application hosting-related products of the PAAS platform currently lack a first-link function that can quickly generate applications in the entire life cycle process management of application development, deployment, monitoring, and operation and maintenance.
- the engineering initialization method proposed in this article can supplement this link capability and improve related The industry competitiveness of the product.
- An embodiment of the present invention further provides a storage medium, in which a computer program is stored, wherein the computer program is configured to implement the steps of any of the above method embodiments when running.
- the above storage medium may be configured to store a computer program for performing the following steps:
- S1 obtaining a creation request for creating a project from a front-end user through a front-end service module, wherein the creation request for creating a project is created by the front-end user inputting page parameters and clicking Create;
- the front-end service module sends a request to create a project to the back-end service module, and the back-end service module calls the Maven process module to read the meta-data.xml file in the skeleton project module;
- the Maven process module After obtaining the project creation rules by reading the meta-data.xml file in the skeleton project module, the Maven process module completes the creation of a customized Maven project and generates a template project;
- the Maven process module generates a customized Maven project to a fixed path, where the fixed path is from the Maven process module to the backend service module.
- the backend service module compresses and packages the customized Maven project and sends it to the user module.
- the above-mentioned storage medium may include but is not limited to: U disk, read-only memory (ROM), random access memory (RAM), mobile hard disk, magnetic disk or optical disk and other media that can store computer programs.
- the Java project initialization method proposed in this article provides fine-grained integration of engineering capabilities: not only can the package name and project name be customized, but also the engineering capabilities can be customized and integrated (currently all are based on Spring Boot, and other frameworks can be supported in the future); the template automatically imports dependencies and integrates capabilities: eliminating the trouble of manually adding dependencies and necessary configuration items, eliminating the need to resolve version conflicts between dependencies, reducing developers' maintenance time on pom files, and focusing on business development; the template can provide basic sample code and documentation: providing basic usage examples of the imported capabilities, with usage instructions and official website document links in the Readme, etc., reducing developers' time searching for usage and self-testing, and improving development efficiency; more suitable for microservice application construction: for the construction of microservice applications, it provides more practical options, and is more suitable for integration with microservice platform-related products.
- the application hosting-related products of the PAAS platform currently lack a method that can quickly generate and manage the entire life cycle process of application development, deployment, monitoring, and operation and maintenance.
- the engineering initialization method proposed in this paper can complement the first link function of the application and improve the industry competitiveness of related products.
- An embodiment of the present invention further provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
- the electronic device may further include a transmission device and an input/output device, wherein the transmission device is connected to the processor, and the input/output device is connected to the processor.
- the processor may be configured to perform the following steps through a computer program:
- S1 obtaining a creation request for creating a project from a front-end user through a front-end service module, wherein the creation request for creating a project is created by the front-end user inputting page parameters and clicking Create;
- the front-end service module sends a request to create a project to the back-end service module, and the back-end service module calls the Maven process module to read the meta-data.xml file in the skeleton project module;
- the Maven process module After obtaining the project creation rules by reading the meta-data.xml file in the skeleton project module, the Maven process module completes the creation of a customized Maven project and generates a template project;
- the Maven process module generates a customized Maven project to a fixed path, where the fixed path is from the Maven process module to the backend service module.
- the backend service module compresses and packages the customized Maven project and sends it to the user module.
- the Java project initialization method proposed in this article provides fine-grained integration of engineering capabilities: not only can the package name and project name be customized, but also the engineering capabilities can be customized and integrated (currently all are based on Spring Boot, and other frameworks can be supported in the future); the template automatically imports dependencies and integrates capabilities: eliminating the trouble of manually adding dependencies and necessary configuration items, eliminating the need to resolve version conflicts between dependencies, reducing developers' maintenance time on pom files, and focusing on business development; the template can provide basic sample code and documentation: providing basic usage examples of the imported capabilities, with usage instructions and official website document links in the Readme, etc., reducing developers' time searching for usage and self-testing, and improving development efficiency; more suitable for microservice application construction: for the construction of microservice applications, it provides more practical options, and is more suitable for integration with microservice platform-related products.
- the application hosting-related products of the PAAS platform when it comes to application In the entire life cycle process management of development, deployment, monitoring, and operation and maintenance, there is currently a lack of a first-link function that can quickly generate applications.
- the engineering initialization method proposed in this article can supplement the capabilities of this link and improve the industry competitiveness of related products.
- the disclosed devices can be implemented in other ways.
- the device embodiments described above are only schematic, such as the division of the above units, which is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed.
- Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection of devices or units can be electrical or other forms.
- the units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
- each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
- the above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
- the above integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable memory.
- the technical solution of the present invention or the part that contributes to the prior art or the whole or part of the technical solution can be embodied in the form of a software product, which is stored in a memory and includes several instructions for enabling a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the above methods of various embodiments of the present invention.
- the aforementioned memory includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other media that can store program codes.
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- General Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Computer Security & Cryptography (AREA)
- Stored Programmes (AREA)
Abstract
本发明公开了一种可定制化Java工程初始化方法及系统,方法包括:通过前端服务模块获取前端用户用于创建项目的创建请求,创建项目的创建请求通过前端用户输入页面参数点击创建;前端服务模块将创建项目的创建请求发送到后端服务模块,后端服务模块调用Maven进程模块读取骨架工程模块中meta-data.xml文件获取项目创建规则后,Maven进程模块完成定制化Maven项目创建,生成模板工程;Maven进程模块生成定制化Maven项目到固定路径,固定路径是由Maven进程模块到后端服务模块,后端服务模块将定制化Maven项目压缩打包后发送给用户模块,本发明方法能够快速初始化SpringBoot工程,通过导入相关依赖、解决依赖冲突、生成各类用法说明的方式,极大提高开发者的项目创建效率、降低依赖维护成本。
Description
本发明属于计算机技术领域,具体涉及一种可定制化Java工程初始化方法及系统。
软件工程的后端开发工作通常需要创建Java工程项目,也即代码工程的初始化。目前SpringBoot框架是Java后端的主流开发框架,其中包含大量实用的开发组件,这些开发组件以依赖的形式被Maven所管理,从而被导入到工程中为工程提供相应能力。项目工程的初始化是所有开发人员开发新组件、新应用时无法绕过的一步,项目工程初始化的耗时、初始化后项目所呈现的形态,直接影响到整体项目的开发进度。目前,开发人员在项目初始化阶段存在以下的痛点:
1.大量SpringBoot项目的首次创建均是基于空模板,各种组件依赖需要依次手工导入;
2.开发后期,依赖项较为复杂时,容易产生依赖版本的冲突,影响开发效率;
3.依赖导入后,工程中仍缺乏所导入组件功能的用法、示例,同样影响开发效率。
对此,业界已经提出了很多SpringBoot项目快速生成和初始化的服务,这些服务可被免费在线使用。其中包括Spring官方的Spring initializer,以及阿里云后续推出的Aliyun Java Initializr,这些工具和服务都能在一定程度上加快开发者创建Springboot项目的速度,并在创建时提供可选项,根据开发者的需求,为创建后的项目工程添加对应的代码段,从而导入相关依赖,为工程赋予对应的能力。然而,现存的项目生成服务存在以下的技术缺陷:
1.很多项目生成服务只能提供项目名称、工程结构级别的定制,无法对具
体的开发组件和开发能力进行定制;
2.很多项目生成服务无法为新创建的工程提供完整的用法示例和Readme文件;
3.很多项目生成服务无法提供细粒度的代码段定制。
因此,导致生成的工程缺乏足够的可定制性,很多代码段需要开发者在后期手动补足,大大延长了开发时间。
发明内容
本发明的目的是提供一种可定制化Java工程初始化方法及系统,以解决现有技术中的不足,它通过首次提出了模板工程生成服务的概念,该服务能够快速初始化SpringBoot工程,通过导入相关依赖、解决依赖冲突、生成各类用法说明的方式,极大提高开发者的项目创建效率、降低依赖维护成本。
本申请的一个实施例提供了一种可定制化Java工程初始化方法包括:
通过前端服务模块获取前端用户用于创建项目的创建请求,所述创建项目的创建请求通过前端用户输入页面参数点击创建;
所述前端服务模块将创建项目的创建请求发送到后端服务模块,所述后端服务模块调用Maven进程模块读取骨架工程模块中meta-data.xml文件;
通过所述读取骨架工程模块中meta-data.xml文件获取项目创建规则后,所述Maven进程模块完成定制化Maven项目创建,生成模板工程;
所述Maven进程模块生成定制化Maven项目到固定路径,所述固定路径是由Maven进程模块到后端服务模块,所述后端服务模块将所述定制化Maven项目压缩打包后发送给用户模块。
可选的,所述Maven进程模块完成定制化Maven项目创建的步骤包括:
所述后端服务模块调用所述Maven进程模块执行archetype:generate指令;
所述Maven进程模块拉取本地中对应名称的骨架工程,找到所述骨架工程特定路径下的archetype-metadata.xml文件;
获取所述创建项目的生成配置,所述Maven进程模块开始执行所述创建项目的任务。
可选的,所述Maven进程模块开始执行所述创建项目的任务还包括读取骨架工程模块中的骨架velocity模板文件,渲染出定制化的代码工程文件。
可选的,所读取骨架工程模块中的骨架velocity模板文件,渲染出定制化的代码工程文件,包括:
替换所述骨架velocity模板文件中的相应字段;
根据输入参数对现有代码段进行增删,完成对应依赖导入;
所述根据输入参数对现有代码文件进行删除,删除不需要代码文件对应的模板文件。
可选的,所述骨架工程模块包含有若干组,所述模板工程提供所导入能力的基本用法示例。
可选的,所述方法还包括模版生成服务的搭建,具体步骤如下:
搭建前端服务,所述搭建前端服务为用户提供工程创建和可选项展示界面;
搭建后端服务,所述接收前端服务的创建请求,解析用户的定制参数项;
开发maven archetype骨架工程,所述开发maven archetype骨架工程完成后使用mvn install指令安装到本地maven仓库。
可选的,一种可定制化Java工程初始化系统。
本申请的又一实施例提供了一种可定制化Java工程初始化系统,所述系统包括:
用户模块,所述用户模块用于前端用户点击创建按钮,创建项目的创建请求
前端服务模块,所述前端服务模块用于传递创建参数给后端服务模块,并将所述定制化Maven项目压缩后返回给用户模块;
后端服务模块,所述后端服务模块用于接收所述前端服务模块创建项目的创建请求并调用Maven进程模块执行计算机指令;
Maven进程模块,所述Maven进程模块用于读取骨架工程中的文件获取创建规则;
骨架工程模块,所述骨架工程模块用于通过创建参数创建项目框架。
本申请的又一实施例提供了一种存储介质,所述存储介质中存储有计算机程序,其中,所述计算机程序被设置为运行时实现上述任一项中所述的方法。
本申请的又一实施例提供了一种电子设备,包括存储器和处理器,所述存储器中存储有计算机程序,所述处理器被设置为运行所述计算机程序以实现上述任一项中所述的方法。
与现有技术相比,本文提出的Java工程初始化方法提供细粒度的工程能力融入:不但可以对包名、项目名进行定制,还可以对工程能力进行定制和融入(目前均是基于Spring Boot,后期可支持其他框架);模板自动导入依赖并融入能力:免去手动添加依赖和必要配置项的麻烦,免解决依赖间的版本冲突,减少开发者对pom文件的维护时间,集中于业务开发;模板可提供基本示例代码及文档:提供所导入能力的基本用法示例,Readme中附用法说明和官网文档链接等,减少开发者搜索用法和自测的时间,提升开发效率;更适用于微服务应用搭建:针对微服务应用的搭建,提供更多实用的可选项,更适合与微服务平台相关产品接轨。例如,PAAS平台的应用托管相关产品,在对应用开发、部署、监控、运维的整个生命周期流程管理中,现缺少一个能够快速生成应用的第一环节功能,本文提出的工程初始化方法即可补足该环节能力,提高相关产品的行业竞争力。
图1为本发明实施例提供的一种可定制化Java工程初始化系统框图;
图2为本发明实施例提供的一种可定制化Java工程初始化方法的流程示意图;
图3为本发明实施例提供的模板工程生成服务骨架工程代码结构示例图;
图4为本发明实施例提供的使用可定制化Java工程初始化方法生成的一个Java工程代码结构示例图。
下面通过参考附图描述的实施例是示例性的,仅用于解释本发明,而不能解释为对本发明的限制。
本发明实施例首先提供了一种可定制化Java工程初始化方法,该方法可以应用于电子设备,如计算机终端,具体如普通电脑、量子计算机等。
参见图2,图2为本发明实施例提供的一种可定制化Java工程初始化方法的流程示意图,可以包括如下步骤:
S1:通过前端服务模块获取前端用户用于创建项目的创建请求,所述创建项目的创建请求通过前端用户输入页面参数点击创建;
S2:所述前端服务模块将创建项目的创建请求发送到后端服务模块,所述后端服务模块调用Maven进程模块读取骨架工程模块中meta-data.xml文件;
S3:通过所述读取骨架工程模块中meta-data.xml文件获取项目创建规则后,所述Maven进程模块完成定制化Maven项目创建,生成模板工程;
S4:所述Maven进程模块生成定制化Maven项目到固定路径,所述固定路径是由Maven进程模块到后端服务模块,所述后端服务模块将所述定制化Maven项目压缩打包后发送给用户模块。
具体的,模板工程生成服务为用户提供友好的项目生成和订制界面,前端用户点击创建按钮,项目创建请求发出后,后端调用maven进程执行mvn
archetype:generate指令,maven进程从本地拉取对应的骨架工程,通过读取骨架工程中的meta-data.xml文件获取创建规则,完成定制化项目创建,后端将项目压缩后返回给用户,供用户下载使用。
其中,由骨架工程生成定制化项目的流程细节如下:
1、Maven进程接收到archetype:generate指令;
2、Maven进程拉取本地中对应名称的骨架工程,找到骨架工程特定路径下的archetype-metadata.xml文件,获取项目生成配置;
3、Mavan进程开始执行项目创建任务,读取骨架工程中的骨架velocity模板文件,渲染出定制化的代码工程文件。
在一种可选的实施方式中,Mavan进程开始执行项目创建任务,读取骨架工程中的骨架velocity模板文件,渲染出定制化的代码工程文件,其中包括:
替换模板中的相应字段,如项目名称、机构、作者、工程服务名等字段;
根据输入参数对现有代码段进行增删,如修改pom.xml文件,完成对应依赖导入;
根据输入参数对现有代码文件进行删除,删除不需要的模板文件,仅留下用户所需依赖能力的对应代码类、示例代码和说明文件等。
进一步的,模板工程生成服务的具体搭建步骤如下:
步骤1、搭建前端服务,为用户提供友好的工程创建和可选项展示界面,最终呈现的界面效果如图2所示;
步骤2、搭建后端服务,接收前端创建请求,解析用户定制参数项,即时调用maven进程执行带参数的mvn archetype:generate指令。最终的拼装指令类如下:
mvn archetype:generate
"-DgroupId=com.zhouzhao"
"-DartifactId=test-from-archetype-v1"
"-Dversion=2.0.0-SNAPSHOT"
"-Dauthor=zhouzhao"
"-Dpackage=com.zhouzhao.test.from.archetype.v1"
"-DarchetypeGroupId=com.ctg.mse.platform"
"-DarchetypeArtifactId=svc-api"
"-DarchetypeVersion=1.2.0-SNAPSHOT"
"-DarchetypeCatalog=local"
"-DinteractiveMode=false"
"-Dredis=false"
"-Dmysql=false";
步骤3、开发maven archetype骨架工程,主要涉及定制参数的接收和处理、项目工程结构设计、velocity模板文件编写、生成测试等环节。骨架工程开发完成后,使用mvn install指令安装到本地maven仓库。所开发的骨架工程代码结构类如图3所示。
通过以上步骤,即可开发一套完整的模板工程生成服务。完成部署后,使用此服务即可实现Java工程的高度定制化。使用该初始化方法生成的Java工程可以快捷地用于业务增量开发,一个所生成的Java工程的目录结构示例如图4所示,根据用户的需求,该工程被生成为包含MySQL能力以及Nacos注册中心能力,MySQL相关代码会被生成在图4中java目录的dao包中,Spring相关依赖会被自动导入(pom文件被改写),相关配置会被写入application.yml文件,如图5所示。
本申请的又一实施例提供了一种可定制化Java工程初始化系统,如图1所示的一种可定制化Java工程初始化系统的模块示意图,所述系统包括:
用户模块,所述用户模块用于前端用户点击创建按钮,创建项目的创建请求
前端服务模块,所述前端服务模块用于传递创建参数给后端服务模块,并将所述定制化Maven项目压缩后返回给用户模块;
后端服务模块,所述后端服务模块用于接收所述前端服务模块创建项目的创建请求并调用Maven进程模块执行计算机指令;
Maven进程模块,所述Maven进程模块用于读取骨架工程中的文件获取创建规则;
骨架工程模块,所述骨架工程模块用于通过创建参数创建项目框架。
具体的,Maven进程模块通过坐标的方式获取Jar包,坐标的组成为:公司/组织(groupId)+项目名(artifactId)+版本(version)组成,可以从互联网、本地等多种仓库源获取Jar包。
具体的,后端服务模块创建项目完成后,需要导入所需的jar,要通过【坐标】来导入,其中每个构件都有自己的坐标(标识)=groupId+artifactId+version=项目标识+项目名+版本,在定制化Maven项目中只需要配置坐标,maven便会自动加载对应依赖,删除坐标则会移除依赖,同时jar包并不会导入到项目目录中,只是Maven进程模块帮助做了关联。但在打包部署项目时会携带对应依赖,如果导入了依赖A,而A中又依赖了B,则B会被自动加载。
与现有技术相比,本发明中不但可以对包名、项目名进行定制,还可以对工程能力进行定制和融入;而且模板自动导入依赖并融入能力:免去手动添加依赖和必要配置项的麻烦,免解决依赖间的版本冲突,减少开发者对pom文件的维护时间,集中于业务开发,同时本发明中的模板可提供基本示例代码及文档:提供所导入能力的基本用法示例,Readme中附用法说明和官网文档链接等,减少开发者搜索用法和自测的时间,提升开发效率,本发明更适用于微服务应用搭建:针对微服务应用的搭建,提供更多实用的可选项,更适合与微服务平台相关产品接轨。例如,PAAS平台的应用托管相关产品,在对应用开发、部署、监控、运维的整个生命周期流程管理中,现缺少一个能够快速生成应用的第一环节功能,本文提出的工程初始化方法即可补足该环节能力,提高相关
产品的行业竞争力。
本发明实施例还提供了一种存储介质,所述存储介质中存储有计算机程序,其中,所述计算机程序被设置为运行时实现上述任一项方法实施例中的步骤。
具体的,在本实施例中,上述存储介质可以被设置为存储用于执行以下步骤的计算机程序:
S1:通过前端服务模块获取前端用户用于创建项目的创建请求,所述创建项目的创建请求通过前端用户输入页面参数点击创建;
S2:所述前端服务模块将创建项目的创建请求发送到后端服务模块,所述后端服务模块调用Maven进程模块读取骨架工程模块中meta-data.xml文件;
S3:通过所述读取骨架工程模块中meta-data.xml文件获取项目创建规则后,所述Maven进程模块完成定制化Maven项目创建,生成模板工程;
S4:所述Maven进程模块生成定制化Maven项目到固定路径,所述固定路径是由Maven进程模块到后端服务模块,所述后端服务模块将所述定制化Maven项目压缩打包后发送给用户模块。
具体的,在本实施例中,上述存储介质可以包括但不限于:U盘、只读存储器(Read-Only Memory,简称为ROM)、随机存取存储器(Random Access Memory,简称为RAM)、移动硬盘、磁碟或者光盘等各种可以存储计算机程序的介质。
与现有技术相比,本文提出的Java工程初始化方法提供细粒度的工程能力融入:不但可以对包名、项目名进行定制,还可以对工程能力进行定制和融入(目前均是基于Spring Boot,后期可支持其他框架);模板自动导入依赖并融入能力:免去手动添加依赖和必要配置项的麻烦,免解决依赖间的版本冲突,减少开发者对pom文件的维护时间,集中于业务开发;模板可提供基本示例代码及文档:提供所导入能力的基本用法示例,Readme中附用法说明和官网文档链接等,减少开发者搜索用法和自测的时间,提升开发效率;更适用于微服务应用搭建:针对微服务应用的搭建,提供更多实用的可选项,更适合与微服务平台相关产品接轨。例如,PAAS平台的应用托管相关产品,在对应用开发、部署、监控、运维的整个生命周期流程管理中,现缺少一个能够快速生
成应用的第一环节功能,本文提出的工程初始化方法即可补足该环节能力,提高相关产品的行业竞争力。
本发明实施例还提供了一种电子设备,包括存储器和处理器,所述存储器中存储有计算机程序,所述处理器被设置为运行所述计算机程序以执行上述任一项方法实施例中的步骤。
具体的,上述电子设备还可以包括传输设备以及输入输出设备,其中,该传输设备和上述处理器连接,该输入输出设备和上述处理器连接。
具体的,在本实施例中,上述处理器可以被设置为通过计算机程序执行以下步骤:
S1:通过前端服务模块获取前端用户用于创建项目的创建请求,所述创建项目的创建请求通过前端用户输入页面参数点击创建;
S2:所述前端服务模块将创建项目的创建请求发送到后端服务模块,所述后端服务模块调用Maven进程模块读取骨架工程模块中meta-data.xml文件;
S3:通过所述读取骨架工程模块中meta-data.xml文件获取项目创建规则后,所述Maven进程模块完成定制化Maven项目创建,生成模板工程;
S4:所述Maven进程模块生成定制化Maven项目到固定路径,所述固定路径是由Maven进程模块到后端服务模块,所述后端服务模块将所述定制化Maven项目压缩打包后发送给用户模块。
与现有技术相比,本文提出的Java工程初始化方法提供细粒度的工程能力融入:不但可以对包名、项目名进行定制,还可以对工程能力进行定制和融入(目前均是基于Spring Boot,后期可支持其他框架);模板自动导入依赖并融入能力:免去手动添加依赖和必要配置项的麻烦,免解决依赖间的版本冲突,减少开发者对pom文件的维护时间,集中于业务开发;模板可提供基本示例代码及文档:提供所导入能力的基本用法示例,Readme中附用法说明和官网文档链接等,减少开发者搜索用法和自测的时间,提升开发效率;更适用于微服务应用搭建:针对微服务应用的搭建,提供更多实用的可选项,更适合与微服务平台相关产品接轨。例如,PAAS平台的应用托管相关产品,在对应用
开发、部署、监控、运维的整个生命周期流程管理中,现缺少一个能够快速生成应用的第一环节功能,本文提出的工程初始化方法即可补足该环节能力,提高相关产品的行业竞争力。
需要说明的是,对于前述的各方法实施例,为了简单描述,故将其都表述为一系列的动作组合,但是本领域技术人员应该知悉,本发明并不受所描述的动作顺序的限制,因为依据本发明,某些步骤可以采用其他顺序或者同时进行。其次,本领域技术人员也应该知悉,说明书中所描述的实施例均属于优选实施例,所涉及的动作和模块并不一定是本发明所必须的。
在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述的部分,可以参见其他实施例的相关描述。
在本发明所提供的几个实施例中,应该理解到,所揭露的装置,可通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如上述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性或其它的形式。
上述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。
另外,在本发明各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。
上述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储器中。基于这样的理解,本发明
的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储器中,包括若干指令用以使得一台计算机设备(可为个人计算机、服务器或者网络设备等)执行本发明各个实施例上述方法的全部或部分步骤。而前述的存储器包括:U盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、移动硬盘、磁碟或者光盘等各种可以存储程序代码的介质。
以上对本发明实施例进行了详细介绍,本文中应用了具体个例对本发明的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本发明的方法及其核心思想;同时,对于本领域的一般技术人员,依据本发明的思想,在具体实施方式及应用范围上均会有改变之处,综上所述,本说明书内容不应理解为对本发明的限制。
Claims (10)
- 一种可定制化Java工程初始化方法,其特征在于,所述方法包括:通过前端服务模块获取前端用户用于创建项目的创建请求,所述创建项目的创建请求通过前端用户输入页面参数点击创建;所述前端服务模块将创建项目的创建请求发送到后端服务模块,所述后端服务模块调用Maven进程模块读取骨架工程模块中meta-data.xml文件;通过所述读取骨架工程模块中meta-data.xml文件获取项目创建规则后,所述Maven进程模块完成定制化Maven项目创建,生成模板工程;所述Maven进程模块生成定制化Maven项目到固定路径,所述固定路径是由Maven进程模块到后端服务模块,所述后端服务模块将所述定制化Maven项目压缩打包后发送给用户模块。
- 根据权利要求1所述的一种可定制化Java工程初始化方法,其特征在于,所述Maven进程模块完成定制化Maven项目创建的步骤包括:所述后端服务模块调用所述Maven进程模块执行archetype:generate指令;所述Maven进程模块拉取本地中对应名称的骨架工程,找到所述骨架工程特定路径下的archetype-metadata.xml文件;获取所述创建项目的生成配置,所述Maven进程模块开始执行所述创建项目的任务。
- 根据权利要求2所述的一种可定制化Java工程初始化方法,其特征在于,所述Maven进程模块开始执行所述创建项目的任务还包括读取骨架工程模块中的骨架velocity模板文件,渲染出定制化的代码工程文件。
- 根据权利要求3所述的一种可定制化Java工程初始化方法,其特征在于,所读取骨架工程模块中的骨架velocity模板文件,渲染出定制化的代码工程文件,包括:替换所述骨架velocity模板文件中的相应字段;根据输入参数对现有代码段进行增删,完成对应依赖导入;所述根据输入参数对现有代码文件进行删除,删除不需要代码文件对应的模板文件。
- 根据权利要求4所述的一种可定制化Java工程初始化方法,其特征在于,所述骨架工程模块包含有若干组,所述模板工程提供所导入能力的基本用法示例。
- 根据权利要求5所述的一种可定制化Java工程初始化方法,其特征在于,所述方法还包括模版生成服务的搭建,具体步骤如下:搭建前端服务,所述搭建前端服务为用户提供工程创建和可选项展示界面;搭建后端服务,所述接收前端服务的创建请求,解析用户的定制参数项;开发maven archetype骨架工程,所述开发maven archetype骨架工程完成后使用mvn install指令安装到本地maven仓库。
- 根据权利要求6所述的一种可定制化Java工程初始化方法,其特征在于,所述开发maven archetype骨架工程包括:用户定制参数的接收和处理,用于接收处理所述解析用户的定制参数项;项目工程结构设计,对不同的场景去抽象不同的模块,通过通过依赖关系对项目工程结构进行设计对骨架velocity模板文件编写;maven archetype骨架工程生成测试环节,使用Maven命令或者集成开发环境中的测试插件执行测试用例,并生成测试报告。
- 一种可定制化Java工程初始化系统,其特征在于,所述系统包括:用户模块,所述用户模块用于前端用户点击创建按钮,创建项目的创建请求前端服务模块,所述前端服务模块用于传递创建参数给后端服务模块,并将所述定制化Maven项目压缩后返回给用户模块;后端服务模块,所述后端服务模块用于接收所述前端服务模块创建项目的创建请求并调用Maven进程模块执行计算机指令;Maven进程模块,所述Maven进程模块用于读取骨架工程中的文件获取创建规则;骨架工程模块,所述骨架工程模块用于通过创建参数创建项目框架。
- 一种存储介质,其特征在于,所述存储介质中存储有计算机程序,其中,所述计算机程序被设置为运行时实现所述权利要求1至7任一项中所述的方法。
- 一种电子设备,包括存储器和处理器,其特征在于,所述存储器中存 储有计算机程序,所述处理器被设置为运行所述计算机程序以实现所述权利要求1至7任一项中所述的方法。
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202311712621.8A CN118132041A (zh) | 2023-12-13 | 2023-12-13 | 一种可定制化Java工程初始化方法及系统 |
| CN202311712621.8 | 2023-12-13 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2025007532A1 true WO2025007532A1 (zh) | 2025-01-09 |
Family
ID=91244637
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2023/142715 Pending WO2025007532A1 (zh) | 2023-12-13 | 2023-12-28 | 一种可定制化Java工程初始化方法及系统 |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN118132041A (zh) |
| WO (1) | WO2025007532A1 (zh) |
Citations (7)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN111290753A (zh) * | 2020-01-20 | 2020-06-16 | 远光软件股份有限公司 | 前端开发环境的搭建方法、装置、设备及存储介质 |
| CN113127098A (zh) * | 2021-04-30 | 2021-07-16 | 康键信息技术(深圳)有限公司 | 基于微服务架构的应用程序创建方法及相关设备 |
| CN113805877A (zh) * | 2021-09-26 | 2021-12-17 | 工银科技有限公司 | 基于idea插件的项目工程的构建方法及装置 |
| CN114564175A (zh) * | 2022-01-27 | 2022-05-31 | 广东南方数码科技股份有限公司 | 软件开发方法、智能终端及存储介质 |
| CN115658025A (zh) * | 2022-07-15 | 2023-01-31 | 大连锦程网络技术有限公司 | 一种高性能分离式架构前端脚手架设计方法 |
| CN115951879A (zh) * | 2022-12-27 | 2023-04-11 | 北京火山引擎科技有限公司 | 模板代码生成方法、装置、系统、介质和电子设备 |
| CN117055858A (zh) * | 2023-08-22 | 2023-11-14 | 固德威技术股份有限公司 | 一种前端脚手架的搭建方法 |
Family Cites Families (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN114995808A (zh) * | 2022-06-13 | 2022-09-02 | 中国银行股份有限公司 | 一种快速搭建微服务工程的方法及装置 |
-
2023
- 2023-12-13 CN CN202311712621.8A patent/CN118132041A/zh active Pending
- 2023-12-28 WO PCT/CN2023/142715 patent/WO2025007532A1/zh active Pending
Patent Citations (7)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN111290753A (zh) * | 2020-01-20 | 2020-06-16 | 远光软件股份有限公司 | 前端开发环境的搭建方法、装置、设备及存储介质 |
| CN113127098A (zh) * | 2021-04-30 | 2021-07-16 | 康键信息技术(深圳)有限公司 | 基于微服务架构的应用程序创建方法及相关设备 |
| CN113805877A (zh) * | 2021-09-26 | 2021-12-17 | 工银科技有限公司 | 基于idea插件的项目工程的构建方法及装置 |
| CN114564175A (zh) * | 2022-01-27 | 2022-05-31 | 广东南方数码科技股份有限公司 | 软件开发方法、智能终端及存储介质 |
| CN115658025A (zh) * | 2022-07-15 | 2023-01-31 | 大连锦程网络技术有限公司 | 一种高性能分离式架构前端脚手架设计方法 |
| CN115951879A (zh) * | 2022-12-27 | 2023-04-11 | 北京火山引擎科技有限公司 | 模板代码生成方法、装置、系统、介质和电子设备 |
| CN117055858A (zh) * | 2023-08-22 | 2023-11-14 | 固德威技术股份有限公司 | 一种前端脚手架的搭建方法 |
Also Published As
| Publication number | Publication date |
|---|---|
| CN118132041A (zh) | 2024-06-04 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN113312037B (zh) | 应用于微服务的数据处理方法、装置、设备和存储介质 | |
| CN104793946B (zh) | 基于云计算平台的应用部署方法和系统 | |
| CN113760362B (zh) | 应用程序的移植方法、装置、设备及介质 | |
| CN110187910B (zh) | 一种热更新方法、装置、设备及计算机可读存储介质 | |
| CN108027722A (zh) | 在编译和部署中动态更新应用 | |
| CN111880801A (zh) | 应用程序动态化方法、装置、电子设备 | |
| CN109284222B (zh) | 软件单元、数据处理系统中的项目测试方法、装置及设备 | |
| CN112860260A (zh) | 一种在高校场景下基于web的跨平台应用构建工具及方法 | |
| CN105677302A (zh) | 一种应用程序模块化开发方法以及装置 | |
| CN111399840A (zh) | 一种模块开发方法及装置 | |
| CN112685020A (zh) | 动态创建服务接口的方法、装置、电子设备及存储介质 | |
| CN114860202A (zh) | 项目运行方法、装置、服务器及存储介质 | |
| CN115291946A (zh) | 鸿蒙系统移植方法、装置、电子设备及可读介质 | |
| CN116679912B (zh) | 代码生成方法、装置、设备、存储介质及计算机程序 | |
| CN113987337A (zh) | 基于组件化动态编排的搜索方法、系统、设备及存储介质 | |
| CN117149162A (zh) | 一种sdk自动生成方法、装置、电子设备及存储介质 | |
| CN117093286A (zh) | 插件生成方法、装置、设备及计算机可读存储介质 | |
| CN109697076A (zh) | 一种应用软件资源的动态更新方法、装置及设备 | |
| CN112068879A (zh) | 基于配置化的客户端应用程序开发框架构建方法及装置 | |
| CN116974555A (zh) | 软件开发工具包的组装方法、装置、设备以及存储介质 | |
| CN115202630A (zh) | 一种基于web前端工程的脚手架构建方法 | |
| CN111290740A (zh) | 应用程序的开发方法、装置、计算机设备和存储介质 | |
| CN115840617A (zh) | 一种调试方法、系统及相关装置 | |
| CN113485740A (zh) | 一种一键自动化打包方法、装置、设备及介质 | |
| Clingan et al. | Kubernetes Native Microservices with Quarkus and MicroProfile |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 23944253 Country of ref document: EP Kind code of ref document: A1 |