maven archetype

news2024/9/22 16:51:22

1.简介

maven脚手架是为了创建一个项目模板,以后新建项目都能够复用该模板
maven中模板引擎使用的是velocity,在文件中可以使用它的语法获取变量等操作

2.实现

单模块脚手架实现
image.png

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.example</groupId>
    <artifactId>single-springboot-template</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>maven-archetype</packaging>

    <properties>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven-javadoc-plugin.version>3.2.0</maven-javadoc-plugin.version>
        <maven-source-plugin.version>3.2.1</maven-source-plugin.version>
        <maven-gpg-plugin.version>1.6</maven-gpg-plugin.version>
        <maven-archetype-plugin.version>3.2.1</maven-archetype-plugin.version>
        <maven-checksum-plugin.version>1.10</maven-checksum-plugin.version>
    </properties>

    <build>
        <extensions>
            <extension>
                <groupId>org.apache.maven.archetype</groupId>
                <artifactId>archetype-packaging</artifactId>
                <version>${maven-archetype-plugin.version}</version>
            </extension>
        </extensions>

        <plugins>
            <plugin>
                <groupId>net.nicoulaj.maven.plugins</groupId>
                <artifactId>checksum-maven-plugin</artifactId>
                <version>${maven-checksum-plugin.version}</version>
                <executions>
                    <execution>
                        <id>create-checksums</id>
                        <goals>
                            <goal>artifacts</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>2.2.1</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>2.9.1</version>
                <configuration>
                    <encoding>UTF-8</encoding>
                    <aggregate>true</aggregate>
                    <charset>UTF-8</charset>
                    <docencoding>UTF-8</docencoding>
                </configuration>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                        <configuration>
                            <additionalparam>-Xdoclint:none</additionalparam>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-release-plugin</artifactId>
                <version>2.5.3</version>
                <configuration>
                    <autoVersionSubmodules>true</autoVersionSubmodules>
                    <useReleaseProfile>false</useReleaseProfile>
                    <releaseProfiles>release</releaseProfiles>
                    <goals>deploy</goals>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>3.1.0</version>
                <configuration>
                    <includeEmptyDirs>true</includeEmptyDirs>
                    <addDefaultExcludes>false</addDefaultExcludes>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-archetype-plugin</artifactId>
                 <version>${maven-archetype-plugin.version}</version>
                <configuration>
                    <!-- needed to include .gitignore -->
                    <useDefaultExcludes>false</useDefaultExcludes>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

archetype-metadata.xml

<?xml version="1.0" encoding="UTF-8"?>
<archetype-descriptor
  xsi:schemaLocation="https://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.1.0 http://maven.apache.org/xsd/archetype-descriptor-1.1.0.xsd"
  name="xfg-frame-archetype"
  xmlns="https://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.1.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

  <fileSets>
    <fileSet filtered="true" encoding="UTF-8">
      <directory>docs</directory>
      <includes>
        <include>**/**</include>
      </includes>
    </fileSet>
    <fileSet filtered="true" encoding="UTF-8">
      <directory>script</directory>
      <includes>
        <include>**/**</include>
      </includes>
    </fileSet>

    <fileSet filtered="true" encoding="UTF-8">
      <directory>deploy</directory>
      <includes>
        <include>**/**</include>
      </includes>
    </fileSet>
    <fileSet encoding="UTF-8">
      <directory/>
      <includes>
        <include>README.md</include>
        <include>.gitignore</include>
      </includes>
    </fileSet>

    <fileSet filtered="true" encoding="UTF-8">
      <directory>src/main/java</directory>
      <includes>
        <include>**/**</include>
      </includes>
    </fileSet>
    <fileSet filtered="true" encoding="UTF-8">
      <directory>src/main/resources</directory>
      <includes>
        <include>**/**</include>
      </includes>
    </fileSet>

    <fileSet>
      <directory>src/test/java</directory>
    </fileSet>
  </fileSets>
</archetype-descriptor>

#模板项目安装到本地
mvn claen install

#执行生成项目命令 静默方式不需要用户输入
 mvn archetype:generate -DgroupId=com.wl -DartifactId=demo -Dpackagename=com.wl -DarchetypeGroupId=org.example -DarchetypeArtifactId=single-springboot-template -DarchetypeVersion=1.0-SNAPSHOT  -DinteractiveMode=false

#执行生成项目命令
 mvn archetype:generate -DgroupId=com.wl -DartifactId=demo -Dpackagename=com.wl  -DarchetypeGroupId=org.example -DarchetypeArtifactId=single-springboot-template -DarchetypeVersion=1.0-SNAPSHOT

3.参考文档

  1. https://medium.com/@sybrenbolandit/maven-archetype-deed0160cdeb
  2. Velocity入门到精通(上篇)_velocity教程-CSDN博客

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1946867.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

无人机之起飞过程操作

一、开启无人机电源 1、开启电源时&#xff0c;再次确认无人机各个部件工作正常&#xff0c;传感器未被遮挡&#xff1b; 2、将无人机放置在平坦的地面上&#xff0c;并开启电源。 二、进行预起飞检查 1、通过无人机的控制系统执行预起飞检查&#xff0c;包括检测罗盘、GPS…

【Unity2D 2022:UI】无法拖拽TextMeshPro组件

在预制体Card上挂载了四个Text Mesh Pro组件&#xff0c;分别命名为Name、HP、ATK、Description。 将预制体Card挂载脚本CardDisplay用来在预制体上显示属性&#xff0c;并创建TextMeshPro对象来接收TextMeshPro组件。 using TMPro; using UnityEngine; using UnityEngine.UI;…

Air780EP模块 LuatOS开发-MQTT接入阿里云应用指南

简介 本文简单讲述了利用LuatOS-Air进行二次开发&#xff0c;采用一型一密、一机一密两种方式认证方式连接阿里云。整体结构如图 关联文档和使用工具&#xff1a;LuatOS库阿里云平台 准备工作 Air780EP_全IO开发板一套&#xff0c;包括天线SIM卡&#xff0c;USB线 PC电脑&…

Harmony Next -- 通用标题栏:高度自定义,可设置沉浸式状态,正常状态下为:左侧返回、居中标题,左中右均可自定义视图。

hm_common_title_bar OpenHarmony三方库中心仓&#xff1a;https://ohpm.openharmony.cn/#/cn/detail/common_title_bar 介绍 一款通用标题栏&#xff0c;支持高度自定义&#xff0c;可设置沉浸式状态&#xff0c;正常状态下为&#xff1a;左侧返回、居中标题&#xff0c;左…

uniapp的h5,读取本地txt带标签的文件

效果图 使用的回显的标签是u-parse&#xff0c;下面的网址讲了这个标签的相关 https://www.cnblogs.com/huihuihero/p/12978903.html 导入此插件 https://ext.dcloud.net.cn/plugin?id364 使用 uni.request({// 本地文件url: "/static/互联网医院医师端用户协议.txt…

初学C++30道选择题带答案(1)

题目 (31) 下面程序的输出是 A) 0 0 3 B) 0 1 2 C) 1 0 3 D) 1 1 2 #include <iostream> using namespace std; main() { int a-1,b4,k;k(a<0)&&(!(b--<0)); cout<<k<<a<<b;} (32)以下…

Nginx 怎样处理请求的并发控制?

&#x1f345;关注博主&#x1f397;️ 带你畅游技术世界&#xff0c;不错过每一次成长机会&#xff01; 文章目录 Nginx 怎样处理请求的并发控制&#xff1f;一、并发控制的重要性二、Nginx 中的并发连接限制三、Nginx 的请求队列四、Nginx 的限流机制五、Nginx 的负载均衡策略…

TypeScript中Interface接口的深度探索与实践

定义接口 在TypeScript中&#xff0c;interface是一个强有力的概念&#xff0c;它用于定义类型签名&#xff0c;特别是对象的结构。接口可以用来描述对象应该有哪些属性、方法&#xff0c;以及这些成员的类型。它们是实现类型系统中“鸭子类型”&#xff08;duck typing&#…

小试牛刀-区块链WalletConnect协议数据解密

目录 1.编写目的 2.工作原理 3.分析过程 3.1 websokcet连接 3.2 连接后的消息 3.3 获取sym_key 3.4 解密数据 Welcome to Code Blocks blog 本篇文章主要介绍了 [WalletConnect协议数据解密] ❤博主广交技术好友&#xff0c;喜欢文章的可以关注一下❤ 1.编写目的 最近在…

<HMI><汇川>在汇川IT7000系列的HMI(触摸屏)中,如何为你的画面设置全局样式?

前言 汇川的HMI软件是使用了Qt来编写的,因此在汇川的HMI程序编写过程,是支持使用qt的样式来自定义部件样式的,即qss格式。 概述 汇川的软件本身提供三个系统的style样式,我们可以直接使用,但是,如果系统提供的样式不符合你的需求,那么你可以对其进行修改,或者自己新建…

计算机网络-配置路由器ACL(访问控制列表)

配置访问控制列表ACL 拓扑结构 拓扑结构如下&#xff1a; 要配置一个ACL&#xff0c;禁止PC0访问PC3&#xff0c;禁止PC4访问PC0&#xff0c;其它正常。 配置Router0 配置接口IP地址&#xff1a; interface fastethernet 0/0 ip address 192.168.1.1 255.255.255.0 no shu…

MongoDB教程(二十二):MongoDB固定集合

&#x1f49d;&#x1f49d;&#x1f49d;首先&#xff0c;欢迎各位来到我的博客&#xff0c;很高兴能够在这里和您见面&#xff01;希望您在这里不仅可以有所收获&#xff0c;同时也能感受到一份轻松欢乐的氛围&#xff0c;祝你生活愉快&#xff01; 文章目录 引言一、固定集…

基于JSP的课程思政元素收集遴选系统

你好呀&#xff0c;我是计算机学姐码农小野&#xff01;如果有相关需求&#xff0c;可以私信联系我。 开发语言&#xff1a; Java 数据库&#xff1a; MySQL 技术&#xff1a; JSPJavaBeansServlet 工具&#xff1a; IDE&#xff08;如Eclipse或IntelliJ IDEA&#xff…

vue上传Excel文件并直接点击文件列表进行预览

本文主要内容&#xff1a;用elementui的Upload 组件上传Excel文件&#xff0c;上传后的列表采用xlsx插件实现点击预览表格内容效果。 在项目中可能会有这样的需求&#xff0c;有很多种方法实现。但是不想要跳转外部地址&#xff0c;所以用了xlsx插件来解析表格&#xff0c;并展…

基于FPGA + Qt + OpenCv的人脸考勤系统

一:界面设计 客户端界面设计: 服务端界面设计: 简介:首先服务端在注册界面先注册人脸,然后客户端界面进行人脸识别,将人脸识别的图像发送给服务端以后,服务端在图像数据库里寻找人脸比对,若有数据就将查询到的个人信息发送给客户端,并在客户端显示,查询界面是用来查…

Hadoop、Hive、HBase、数据集成、Scala阶段测试

姓名&#xff1a; 总分&#xff1a;Hadoop、Hive、HBase、数据集成、Scala阶段测试 一、选择题&#xff08;共20道&#xff0c;每道0.5分&#xff09; 1、下面哪个程序负责HDFS数据存储&#xff08; C &#xff09; A. NameNode B. Jobtracher C. DataNode D. Sec…

机器学习数学基础(2)--最大似然函数

声明&#xff1a;本文章是根据网上资料&#xff0c;加上自己整理和理解而成&#xff0c;仅为记录自己学习的点点滴滴。可能有错误&#xff0c;欢迎大家指正。 在机器学习和统计学领域中&#xff0c;似然函数&#xff08;Likelihood Function&#xff09;是一个至关重要的概念。…

苍穹外卖跟练项目前端localhost打不开页面启动nginx报错[alert] could not open error log file问题解决

一、安装路径为纯英文 查看自己的安装路径是否为纯英文环境&#xff0c;刚开始下载的资料包是有中文路径的&#xff0c;要将资料包中的nginx-1.20.2文件夹复制一份然后粘贴到一个新建的纯英文的目录&#xff0c;我这里装到的是 D:\Program Files\nginx-1.20.2 二、删掉logs文件…

解决Pycharm找不到conda可执行文件

解决&#xff1a; 在 ‘Conda 可执行文件’ 的输入框里面&#xff0c;找到并选中 anaconda\library\bin 路径下的“ conda.bat ” ,再点击‘ 加载环境 ’&#xff0c;即可出现 ‘ 使用现有环境 ’ 的输入框&#xff0c;如图所示。

java8函数式编程学习(二):optional,函数式接口和并行流的学习

简介 java8函数式编程中optional的简单使用&#xff0c;函数式接口的了解&#xff0c;并行流的使用。 optional 可以更优雅的来避免空指针异常。类似于包装类&#xff0c;把具体的数据封装到optional对象内部&#xff0c;然后使用optional的方法去操作封装好的数据。 创建o…