-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
一步一步教你如何创建第一个Vert.x Web应用 #10
Comments
支持, 希望有更深入分析的文章 |
cool... |
初学vert.x,关于vert.x有些困惑,看很多地方简介都是对比Node.js,那么vert.x对于Node.js有什么优点呢? 和现在比较流行的springboot+rpc+mq的微服务相比又有什么优劣势呢? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Vert.x是一个支持多语言的运行在JVM之上的开发平台,可以用于构建各种应用,包括web应用,这篇文章教你如何使用Maven和Vert.x创建第一个web应用。
0. 需要JDK 8
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
1. 安装Maven
如果已经安装了,可以跳过这一步
下载Maven: http://archive.apache.org/dist/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.zip
下文我都以Windows 7为例,如果使用Linux,需要修改一下相应的目录名,
把apache-maven-3.3.9-bin.zip解压到D:\apache-maven-3.3.9目录(也可以选择其他目录),
然后把D:\apache-maven-3.3.9\bin加入Path环境变量,
打开一个命令行窗口,输入mvn -version,能看到类似下面的信息:
Apache Maven 3.3.9
2. 创建一个空的Maven项目
mvn archetype:generate -DgroupId=my.test -DartifactId=vertx_app -Dversion=1.0-SNAPSHOT -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
如果在D:\目录下运行上面的命令,会生成一个D:\vertx_app目录,
打开D:\vertx_app\pom.xml文件,用下面的内容替换掉:
(用Vert.x开发最简单的Web应用只需要依赖vertx-web,测试Vert.x应用需要用到vertx-unit)
3. Hello World
文件位置: vertx_app\src\main\java\my\test\HelloWorldVerticle.java
4. 测试类
文件位置:vertx_app\src\test\java\my\HelloWorldVerticleTest.java
5. 使用Maven测试
mvn test
6. 使用Maven打包
mvn clean package -Dmaven.test.skip=true
7. 运行
java -jar target/vertx_app-1.0-SNAPSHOT-fat.jar
如果要停止请按ctrl + c
8. 在浏览器中查看结果
http://localhost:8080/
http://localhost:8080/date
9. 参考文档:
Vert.x-Web Manual
Introduction to Vert.x
The text was updated successfully, but these errors were encountered: