Boilerplate code generator for Vert.x applications.
Vert.x applications are great way to build scalable and reactive applications. But you tends to create more boilerplate code with each vertical. This library aims to reduce those boilerplate code by automatically generating it for your application based on couple of annotations.
It's a class based annotation which generates a HttpVertical for all paths targeted inside the class. Paths are targeted using @Get and @Post annotations on the class methods.
It's a method based annotation which specifies a Get method route for the parent vertical.
It's a method based annotation which specifies a Post method route for the parent vertical.
It's a method based annotation which generates a EventBusVertical for specified path.
- Add dependency to your
pom.xml
<dependency>
<groupId>com.github.riteshkukreja</groupId>
<artifactId>vertx-annotations</artifactId>
<version>1.0.0</version>
</dependency>
- Create a file named
UserHandler.java
and insert following code
@HttpVertical("/user")
public class UserHandler {
@Get("/")
public void sayHello(RoutingContext context) {
context.response().end("Hello");
}
}
- Set generated vertical as your starting vertical.
<properties>
<main.verticle>gen.verticals.MainVerticalGen</main.verticle>
</properties>
<plugins>
<!-- Add Maven shade plugin to generate fat-jar -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Main-Class>io.vertx.core.Launcher</Main-Class>
<Main-Verticle>${main.verticle}</Main-Verticle>
</manifestEntries>
</transformer>
</transformers>
<outputFile>${project.build.directory}/${project.artifactId}-${project.version}-fat.jar</outputFile>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
- Compile and run your fat-jar
java -jar <fat-jar>.jar
Pull requests for new features, bug fixes, and suggestions are welcome!
This project is licensed under MIT