Vertex is java’s micro framework for especial for api driven work.
Create a project
new Project->java ->java console application
then add framework support ->mvn
if you don’t know maven then learn more about maven
then add dependency
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
<dependencies> <dependency> <groupId>io.vertx</groupId> <artifactId>vertx-core</artifactId> <version>3.0.0</version> </dependency> </dependencies> <build> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.3</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> </plugins> </build> |
and
create a class MyFirstVerticle in src->main->java which is root directory
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
import io.vertx.core.AbstractVerticle; import io.vertx.core.Future; public class MyFirstVerticle extends AbstractVerticle { @Override public void start(Future<Void> fut) { vertx .createHttpServer() .requestHandler(r -> { r.response().end("<h1>Hello from my first " + "Vert.x 3 application</h1>"); }) .listen(8080, result -> { if (result.succeeded()) { fut.complete(); } else { fut.fail(result.cause()); } }); } } |
and goto edit configuration
+ application
name VertexRunner
Main Class: io.vertx.core.Starter
Program arguments: run MyFirstVerticle
working directory: [Your project location]
then click ok .
and run http://localhost:8080/
thanks to http://stackoverflow.com/questions/32205477/how-to-start-vert-x-server-from-intellij-idea