Chapter 2. Configuring your applications
This section explains how to configure your applications to work with Eclipse Vert.x runtime. It also describes the procedure to use Agroal in your Eclipse Vert.x applications.
2.1. Configuring your application to use Eclipse Vert.x Copy linkLink copied to clipboard!
Reference the Eclipse Vert.x BOM (Bill of Materials) artifact in the pom.xml file at the root directory of your application.
Prerequisites
- A Maven-based application
Procedure
Open the
pom.xmlfile, add theio.vertx:vertx-dependenciesartifact to the<dependencyManagement>section, and specify the<type>pom</type>and<scope>import</scope>:<project> ... <dependencyManagement> <dependencies> <dependency> <groupId>io.vertx</groupId> <artifactId>vertx-dependencies</artifactId> <version>${vertx.version}</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> ... </project>Include the following properties to track the version of Eclipse Vert.x and the Vert.x Maven Plugin you are using:
<project> ... <properties> <vertx.version>${vertx.version}</vertx.version> <vertx-maven-plugin.version>${vertx-maven-plugin.version}</vertx-maven-plugin.version> </properties> ... </project>Reference
vertx-maven-pluginas the plugin used to package your application:<project> ... <build> <plugins> ... <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> ... </plugins> </build> ... </project>Include
repositoriesandpluginRepositoriesto specify the repositories that contain the artifacts and plugins to build your application:<project> ... <repositories> <repository> <id>redhat-ga</id> <name>Red Hat GA Repository</name> <url>https://maven.repository.redhat.com/ga/</url> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>redhat-ga</id> <name>Red Hat GA Repository</name> <url>https://maven.repository.redhat.com/ga/</url> </pluginRepository> </pluginRepositories> ... </project>
Additional resources
- For more information about packaging your Eclipse Vert.x application, see the Vert.x Maven Plugin documentation.
2.2. Configuring your Eclipse Vert.x application to use Agroal Copy linkLink copied to clipboard!
Starting with Eclipse Vert.x release 3.5.1.redhat-003, Agroal replaced C3PO as the default JDBC connection pool. C3PO and Agroal use different property names. Upgrading to a newer release of Eclipse Vert.x might break the JDBC connection pool configuration of your Eclipse Vert.x applications. Update the property names in the configuration of your JDBC connection pool to avoid this issue.
To continue using C3P0 as the JDBC connection pool for your application, set the value of the provider_class property in your JDBC connection pool configuration to io.vertx.ext.jdbc.spi.impl.C3P0DataSourceProvider.
Procedure
- Update the following property names within your JDBC connection pool configuration to match the connection pool you use:
| C3P0 property name | Agroal property name |
|---|---|
| url | jdbcUrl |
| driver_class | driverClassName |
| user | principal |
| password | credential |
| castUUID | castUUID |
Additional information
Example JDBC connection pool configuration using C3P0:
JsonObject config = new JsonObject() .put("url", JDBC_URL) // set C3P0 as the JDBC connection pool: .put("provider_class", "io.vertx.ext.jdbc.spi.impl.C3P0DataSourceProvider") .put("driver_class", "org.postgresql.Driver") .put("user", JDBC_USER) .put("password", JDBC_PASSWORD) .put("castUUID", true);Example JDBC connection pool configuration using Agroal:
JsonObject config = new JsonObject() .put("jdbcUrl", JDBC_URL) .put("driverClassName", "org.postgresql.Driver") .put("principal", JDBC_USER) .put("credential", JDBC_PASSWORD) .put("castUUID", true);