2.2、添加所需的依赖

第一批添加到pom.xml文件的依赖项是用于Web处理和呈现的依赖:

<dependency>
  <groupId>io.vertx</groupId>
  <artifactId>vertx-web</artifactId>
</dependency>
<dependency>
  <groupId>io.vertx</groupId>
  <artifactId>vertx-web-templ-freemarker</artifactId>
</dependency>
<dependency>
  <groupId>com.github.rjeschke</groupId>
  <artifactId>txtmark</artifactId>
  <version>0.13</version>
</dependency>

Vert.x web为流行的模板引擎提供了可插拔的支持:Handlebars,Jade,MVEL,Pebble,Thymeleaf和Freemarker。

第二组依赖是JDBC数据库访问所需的依赖关系:

<dependency>
  <groupId>io.vertx</groupId>
  <artifactId>vertx-jdbc-client</artifactId>
</dependency>
<dependency>
  <groupId>org.hsqldb</groupId>
  <artifactId>hsqldb</artifactId>
  <version>2.3.4</version>
</dependency>

Vert.x JDBC client 库提供对任何兼容JDBC的数据库的访问,但是当然我们的项目需要在类路径上具有JDBC驱动程序。

HSQLDB是用Java编写的知名关系数据库。当用作嵌入式数据库时,它是非常受欢迎的,以避免在外部运行一个第三方数据库服务器。它也适用于单元和集成测试,因为它提供(易失性)内存存储。

HSQLDB作为嵌入式数据库非常适合初学者。它将数据存储在本地文件中,并且由于HSQLDB库Jar提供了JDBC驱动程序,Vert.x JDBC配置将非常简单。

Vert.x还提供专用的MySQL和PostgreSQL客户端库。

当然,您可以使用通用的Vert.x JDBC客户端连接到MySQL或PostgreSQL数据库,但这些库通过这两个数据库服务器的专用网络协议提供更好的性能
,而不是通过
(阻塞)JDBC API。

Vert.x还提供了与流行的非关系数据库MongoDB和Redis连接的库。较大的社区会提供与其他存储系统(如Apache Cassandra,OrientDB或ElasticSearch)的集成库。

results matching ""

    No results matching ""