文档地址:https://reactiverse.io/vertx-maven-plugin

已有项目添加该插件

在项目 pom.xml 目录,执行下面的命令即可添加:

mvn io.reactiverse:vertx-maven-plugin:1.0.17:setup

执行该命令后,在 pom.xml 中会增加下面的配置:

<properties><vertx.version>3.5.3</vertx.version><vertx-maven-plugin.version>1.0.17</vertx-maven-plugin.version>
</properties>
<dependencyManagement><dependencies><dependency><groupId>io.vertx</groupId><artifactId>vertx-stack-depchain</artifactId><version>${vertx.version}</version><type>pom</type><scope>import</scope></dependency></dependencies>
</dependencyManagement>

还有下面的插件:

<plugin><groupId>io.reactiverse</groupId><artifactId>vertx-maven-plugin</artifactId><version>${vertx-maven-plugin.version}</version><executions><execution><id>vmp</id><goals><goal>initialize</goal><goal>package</goal></goals></execution></executions><configuration><redeploy>true</redeploy></configuration>
</plugin>

自动引入的 vert.x 版本为 3.5.3,你可以通过在 mvn 命令增加 -DvertxVersion=3.4.0 这个参数来指定需要的版本。

从头创建空项目

首先你必须创建一个目录,vert.x 插件不会自动给你创建目录,只会创建目录内的 src 和 pom.xml 等文件。

创建一个目录,进入该目录内,在该目录内执行下面的命令:

mvn io.reactiverse:vertx-maven-plugin:1.0.17:setup ^-DprojectGroupId=org.acme ^
    -DprojectArtifactId=acme-project ^
    -DprojectVersion=1.0-SNAPSHOT ^
    -Dverticle=io.vertx.sample.MyFirstVerticle ^
    -Ddependencies=web

如果你使用的 Linux 系统,将上面的 ^ 改为 \

这里和上面相比增加了项目 GAV 的配置。

通过 -Dverticle=io.vertx.sample.MyFirstVerticle,可以生成一个默认的 Verticle 类。

通过 -Ddependencies=web 可以指定你想加入的 vert.x 的依赖,这里写的名字都是缩写,具体对应关系看下面的介绍。

使用上面命令后,就创建了一个基础 vert.x 项目,在开始学习 vert.x 的时候,通过这种方式可以更快的创建基础项目。

-Ddependencies 对照表

源码:dependencies.json

下面 JSON 中的 labels 就是缩写名,groupId 和 artifactId 是对应的依赖。

[{"name": "Vert.x Web","labels": ["web"],"groupId": "io.vertx","artifactId": "vertx-web"},{"name": "Vert.x Web Client","labels": ["web-client"],"groupId": "io.vertx","artifactId": "vertx-web-client"},{"name": "Vert.x Mongo Client","labels": ["mongo"],"groupId": "io.vertx","artifactId": "vertx-mongo-client"},{"name": "Vert.x Kafka Client","labels": ["kafka"],"groupId": "io.vertx","artifactId": "vertx-kafka-client"},{"name": "Vert.x Consul Client","labels": ["consul"],"groupId": "io.vertx","artifactId": "vertx-consul-client"},{"name": "Vert.x gRPC","labels": ["gRPC"],"groupId": "io.vertx","artifactId": "vertx-grpc"},{"name": "Vert.x (async) JDBC Client","labels": ["jdbc"],"groupId": "io.vertx","artifactId": "vertx-jdbc-client"},{"name": "Vert.x Redis Client","labels": ["redis"],"groupId": "io.vertx","artifactId": "vertx-redis-client"},{"name": "Vert.x Mail Client","labels": ["mail","smtp"],"groupId": "io.vertx","artifactId": "vertx-mail-client"},{"name": "Vert.x STOMP","labels": ["stomp"],"groupId": "io.vertx","artifactId": "vertx-stomp"},{"name": "Vert.x EventBus Bridge using TCP","labels": ["tcp-bridge"],"groupId": "io.vertx","artifactId": "vertx-tcp-eventbus-bridge"},{"name": "Vert.x - Apache Camel bridge","labels": ["camel"],"groupId": "io.vertx","artifactId": "vertx-camel-bridge"},{"name": "Vert.x Bridge with AMQP","labels": ["amqp"],"groupId": "io.vertx","artifactId": "vertx-amqp-bridge"},{"name": "Vert.x Client for RabbitMQ","labels": ["rabbitmq"],"groupId": "io.vertx","artifactId": "vertx-rabbitmq-client"},{"name": "Vert.x Authentication Support using JDBC","labels": ["jdbc-auth"],"groupId": "io.vertx","artifactId": "vertx-auth-jdbc"},{"name": "Vert.x Authentication Support using JWT","labels": ["jwt-auth"],"groupId": "io.vertx","artifactId": "vertx-auth-jwt"},{"name": "Vert.x Authentication Support using Mongo","labels": ["mongo-auth"],"groupId": "io.vertx","artifactId": "vertx-auth-mongo"},{"name": "Vert.x Authentication Support using Shiro","labels": ["shiro-auth"],"groupId": "io.vertx","artifactId": "vertx-auth-shiro"},{"name": "Vert.x Authentication Support using OAuth 2","labels": ["oauth2","oauth2-auth","oauth"],"groupId": "io.vertx","artifactId": "vertx-auth-oauth2"},{"name": "Vert.x support for RX Java","labels": ["rx","rxjava"],"groupId": "io.vertx","artifactId": "vertx-rx-java"},{"name": "Vert.x support for JavaScript (Nashorn)","labels": ["js","javascript"],"groupId": "io.vertx","artifactId": "vertx-lang-js"},{"name": "Vert.x support for Kotlin","labels": ["kotlin","vertx-kotlin"],"groupId": "io.vertx","artifactId": "vertx-lang-kotlin-compiler"},{"name": "Vert.x support for Ruby (JRuby)","labels": ["rb","ruby","jruby"],"groupId": "io.vertx","artifactId": "vertx-lang-ruby"},{"name": "Vert.x support for Apache Groovy","labels": ["groovy"],"groupId": "io.vertx","artifactId": "vertx-lang-groovy"},{"name": "Vert.x Service Discovery","labels": ["discovery","service-discovery"],"groupId": "io.vertx","artifactId": "vertx-service-discovery"},{"name": "Vert.x Circuit Breaker","labels": ["circuit-breaker","circuit"],"groupId": "io.vertx","artifactId": "vertx-circuit-breaker"},{"name": "Vert.x Service Discovery for Kubernetes","labels": ["discovery-kubernetes","service-discovery-kubernetes"],"groupId": "io.vertx","artifactId": "vertx-service-discovery-bridge-kubernetes"},{"name": "Vert.x Service Discovery for Consul","labels": ["discovery-consul","service-discovery-consul"],"groupId": "io.vertx","artifactId": "vertx-service-discovery-bridge-consul"},{"name": "Vert.x Metrics using Dropwizard","labels": ["jmx","dropwizard"],"groupId": "io.vertx","artifactId": "vertx-dropwizard-metrics"},{"name": "Vert.x Metrics using Hawkular","labels": ["hawkular"],"groupId": "io.vertx","artifactId": "vertx-hawkular-metrics"},{"name": "Vert.x Shell","labels": ["shell"],"groupId": "io.vertx","artifactId": "vertx-shell"},{"name": "Vert.x Unit","labels": ["test"],"groupId": "io.vertx","artifactId": "vertx-unit","scope": "test"},{"name": "Vert.x Cluster Manager based on Hazelcast","labels": ["hazelcast","hazelcast-cluster-manager"],"groupId": "io.vertx","artifactId": "vertx-hazelcast"},{"name": "Vert.x Cluster Manager based on Infinipan","labels": ["infinispan","infinispan-cluster-manager"],"groupId": "io.vertx","artifactId": "vertx-infinispan"},{"name": "Vert.x Cluster Manager based on Zookeeper","labels": ["zookeeper-cluster-manager"],"groupId": "io.vertx","artifactId": "vertx-zookeeper"},{"name": "Vert.x Cluster Manager based on Apache Ignite","labels": ["ignite"],"groupId": "io.vertx","artifactId": "vertx-ignite"},{"name": "Vert.x Cluster Manager based on Apache Zookeeper","labels": ["zookeeper"],"groupId": "io.vertx","artifactId": "vertx-zookeeper"},{"name": "Vert.x Web Template Engine based on Pebble","labels": ["pebble","pebble-template","pebble-template-engine"],"groupId": "io.vertx","artifactId": "vertx-web-templ-pebble","classifier": "shaded"},{"name": "Vert.x Web Template Engine based on Apache Freemarker","labels": ["freemarker","freemarker-template","freemarker-template-engine"],"groupId": "io.vertx","artifactId": "vertx-web-templ-freemarker","classifier": "shaded"},{"name": "Vert.x Web Template Engine based on Thymeleaf","labels": ["thymeleaf","thymeleaf-template","thymeleaf-template-engine"],"groupId": "io.vertx","artifactId": "vertx-web-templ-thymeleaf","classifier": "shaded"},{"name": "Vert.x Web Template Engine based on Handlebars","labels": ["handlebars","handlebars-template","handlebars-template-engine"],"groupId": "io.vertx","artifactId": "vertx-web-templ-handlebars","classifier": "shaded"},{"name": "Vert.x Web Template Engine based on Jade","labels": ["jade","jade-template","jade-template-engine"],"groupId": "io.vertx","artifactId": "vertx-web-templ-jade","classifier": "shaded"},{"name": "Vert.x Web Template Engine based on MVEL","labels": ["mvel","mvel-template","mvel-template-engine"],"groupId": "io.vertx","artifactId": "vertx-web-templ-mvel","classifier": "shaded"},{"name": "Vert.x (async) RPC service proxies","labels": ["service-proxies","rpc-services"],"groupId": "io.vertx","artifactId": "vertx-service-proxy"},{"name": "Vert.x Service Factory using Apache Maven","labels": ["maven-service-factory"],"groupId": "io.vertx","artifactId": "vertx-maven-service-factory"},{"name": "Vert.x Service Factory","labels": ["service-factory"],"groupId": "io.vertx","artifactId": "vertx-service-factory"},{"name": "Vert.x Service Factory using HTTP","labels": ["http-service-factory"],"groupId": "io.vertx","artifactId": "vertx-http-service-factory"},{"name": "Vert.x Configuration","labels": ["config"],"groupId": "io.vertx","artifactId": "vertx-config"},{"name": "Vert.x Configuration with Kubernetes ConfigMap","labels": ["config-kubernetes","config-config-map","config-configmap"],"groupId": "io.vertx","artifactId": "vertx-config-kubernetes-configmap"},{"name": "Vert.x Configuration with a Git repository","labels": ["config-git"],"groupId": "io.vertx","artifactId": "vertx-config-git"},{"name": "Vert.x Configuration - HOCON format","labels": ["config-hocon"],"groupId": "io.vertx","artifactId": "vertx-config-hocon"},{"name": "Vert.x Configuration - Yaml format","labels": ["config-yaml"],"groupId": "io.vertx","artifactId": "vertx-config-yaml"},{"name": "Vert.x Configuration with a Zookeeper backend","labels": ["config-zookeeper"],"groupId": "io.vertx","artifactId": "vertx-config-zookeeper"},{"name": "Vert.x Configuration with a Redis backend","labels": ["config-redis"],"groupId": "io.vertx","artifactId": "vertx-config-redis"}
]

打包项目

集成了 vert.x 插件后,打包变的极其容易,只需要下面的命令:

mvn clean package

通过这种方式就会打出一个 fat jar 包,可以直接通过 java -jar xxxx.jar 运行的包。

其他命令

除了上面这些,还有 vertx:run, vertx:debug, vertx:start, vertx:stop命令,这些命令可以在不打 jar 包的情况下运行或者关闭项目。

常见问题

通过插件方式运行时,你经常会遇到下面的问题:

[INFO] 严重: java.net.BindException: Address already in use: bind

这种情况是因为使用类似 IDEA Maven 插件中的命令直接双击运行时,你无法关闭这个应用。如果你使用的纯命令行,直接 Ctrl+C 就能关闭。

使用 vertx:run 在命令行运行时可以直接关闭。
使用 vertx:start 运行时,需要通过 vertx:stop 关闭。

万一遇上无法关闭的情况,在 windows 中,可以用下面方式解决。

在命令行中,输入下面的命令:

jps -m

这个命令会列出所有运行的 jvm:

15248 Jps -m
2384 Launcher run io.vertx.sample.MyFirstVerticle redeploy-termination-period=1000 -Dvertx.id=5fd656fa-55a9-46b4-8d23-caa95f2e5032-redeploy
8208
11844 Launcher run io.vertx.sample.MyFirstVerticle redeploy-termination-period=1000 -Dvertx.id=bec46d01-d441-4949-a2d9-f8ffbe85f965-redeploy
14200 Launcher run io.vertx.sample.MyFirstVerticle --redeploy=F:\Git\my-first-vertx-app\target\classes/**/* --redeploy-scan-period=1000 redeploy-termi
nation-period=1000 --launcher-class=io.vertx.core.Launcher
7580 Launcher clean compile vertx:run

根据后面的信息找到你想关闭的 jvm。输入下面的命令(假设关闭 2384):

taskkill /f /pid 2384

当相同端口的 jvm 关闭后,你就可以再次运行了。

使用 Vert.x Maven 插件快速创建项目相关推荐

  1. Maven使用原型插件来创建项目

    2019独角兽企业重金招聘Python工程师标准>>> 转自:http://www.yiibai.com/spring/maven_creating_project.html Mav ...

  2. 初识 npm script : 用 npm init 快速创建项目

    初识 npm script 首先介绍创建 package.json 文件的科学方法,目标是掌握 npm init 命令.然后,通过在终端中运行自动生成的 test 命令,详细讲解 npm 脚本基本执行 ...

  3. SpringBoot2.X (2)- 使用Spring Initializer 快速创建项目

    SpringBoot - 使用Spring Initializer 快速创建项目 ① New Project 这里不选择Maven,选择Spring Initializer. ② 编写项目类型.项目名 ...

  4. python编程怎么建立工程_教你如何用Python脚本快速创建项目

    相信初学Cocos2D者对Python还很陌生,今天本篇教程教你如何用Python脚本快速创建项目. 在Cocos2d-x2.1.4以上的版本中,取消了使用vs模版创建项目的方法,开始使用python ...

  5. ExtAspNet学习-利用AppBox框架快速创建项目(五)—完成项目含源代码

    我们前边四个部分已经完成了框架需要的基础配置, 现在我们来完成项目 1.Subsonic 配置,首先在OraSurvey.DAO中添加App.config配置相关信息 View Code 1 < ...

  6. 手把手教你使用nodejs编写一个【使用远程仓库模板,快速创建项目模块】的cli(命令行)

    目录 实现步骤 初始化cli项目 项目目录 创建交互式命令 拉取远程仓库代码,读取仓库中的模板 拉取远程仓库代码 ora 终端 loading 读取仓库中的模板 将选择的模板复制写入目标项目 Comm ...

  7. 用Maven Archetype Plugin快速创建项目

    还在用mvn archetype:create -DarchetypeArtifactId=maven-archetype-quickstart -DgroupId=com.ryanote -Dart ...

  8. 使用Maven插件构建SpringBoot项目,生成Docker镜像push到DockerHub上

    一个用于构建和推送Docker镜像的Maven插件. 使用Maven插件构建Docker镜像,将Docker镜像push到DockerHub上,或者私有仓库,上一篇文章是手写Dockerfile,这篇 ...

  9. Jenkins安装svn插件并创建项目

    系统管理-插件管理-搜索Subversion-安装重启即可 安装完成后就会在这个位置生成svn的选项:  Jenkins+svn代码上线系统原理: 1.Jenkins拉取svn服务器代码并打包到Jen ...

最新文章

  1. ROS安装:Ubuntu18.04安装配置ROS-melodic
  2. kafka consumer配置拉取速度慢_Kafka分区分配策略(Partition Assignment Strategy)
  3. 促销海报灵感素材,不卖出去都难
  4. php foreach是什么,php foreach用法是什么
  5. 程序员2009精华本 有哪些精彩值得期待
  6. MySQL Password Expired
  7. 易语言解析html换行,HTML代码查看工具易语言源码
  8. linux红帽子系统作用,linux 红帽子9.0操作系统怎么装?
  9. python语言程序设计袁方答案_北邮“爱课堂”教学平台
  10. USB数据采集卡关于高电压数据采集提供的解决方案
  11. shell笔记_重定向与文本处理命令
  12. 4g内存php一般开多少个进程,Linux_4G内存服务器epoll并发量最大能达到多少?,按照题主的意思 是根据内存去 - phpStudy...
  13. ATMEL芯片系列介绍2
  14. kaggle员工离职预测——SVC
  15. java接口命名 findby getby_三 JPA复杂查询的几种方式
  16. wps将word文档转换为图片格式
  17. 创维宽带猫E910V10C(电信)(酒店使用的那种)改桥接
  18. Leetcode-SQL学习计划-SQL入门-584:寻找用户推荐人
  19. Mysql查询某一年的的12个月份数据
  20. Nginx 之四: Nginx服务器的rewrite、全局变量、重定向和防盗链相关功能

热门文章

  1. 2021朔城区一中高考成绩查询,青春有志逐梦远行—朔城区一中2021届高三毕业典礼暨高考壮行大会...
  2. cosmos官方scavenger_hunt_game测试项目部署
  3. 深度图像和彩色图像配准原理
  4. SpringBoot项目No qualifying bean of type ‘×××Mapper‘ available:的错误解决
  5. 【LeetCode】77. Combinations 解题报告(Python C++)
  6. 控制用计算机应具有特点,国开(中央电大)专科《可编程控制器应用》网上形考、机考试题及答案...
  7. 计算机物流管理专业毕业论文范文,物流管理专业毕业论文范文2020:物流管理专业毕业论文范文...
  8. [Java反序列化]CommonsCollections3利用链学习
  9. ubuntu box_将您的Ubuntu Box转换成卡拉OK机
  10. 26. SAP ABAP OData Gateway 框架里 /IWFND, /IWBEP 这些缩写代表了什么含义?