Vertx入门篇-01 - Hello Vertx

简介: https://vertx.io/docs/vertx-core/java/

Hello Vert.x

1、添加POM相关依赖

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>8</source>
                    <target>8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>io.vertx</groupId>
                <artifactId>vertx-stack-depchain</artifactId>
                <version>3.6.2</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>io.vertx</groupId>
            <artifactId>vertx-core</artifactId>
        </dependency>
    </dependencies>

2、新建VertxHello1,启动一个HttpServer

public class VertxHello1 {
    public static void main(String[] args) {
        // 创建一个 Http Server
        Vertx.vertx().createHttpServer().requestHandler(request -> {
            request.response()
                    .putHeader("Content-Type", "text/plain")
                    .write("Hello Vert.x!")
                    .end();
        }).listen(8080, http -> {
            if (http.succeeded()) {
                System.out.println("HTTP server started on http://localhost:8080");
            }else {
                http.cause().printStackTrace();
            }
        });
    }
}
目录
相关文章
|
Java
JVM之本地内存以及元空间,直接内存的详细解析
JVM之本地内存以及元空间,直接内存的详细解析
1244 0
|
监控 Java Spring
Spring Boot 拦截器(Interceptor)详解
本文介绍Spring Boot拦截器的原理与使用,涵盖自定义拦截器创建、注册配置、执行顺序及典型应用场景,助力提升系统安全性与可维护性。(238字)
949 0
|
Kubernetes 持续交付 开发工具
三类代码协同模式,你要如何选?
三类代码协同模式,Git大神告诉你到底如何选。
|
8月前
|
网络协议 前端开发 数据可视化
Apipost免费版、企业版和私有化部署详解
Apipost 是企业级 API 研发协作一体化平台,提供 API 研发、测试、管理全链路解决方案。支持多种协议(HTTP(s)、WebSocket、gRPC 等),助力团队实时协作、降本增效。免费版适合小微团队,具备 API 设计、调试、自动化测试和文档功能;企业版强化全链路资产管理与管控,支持复杂场景测试。此外,私有化部署方案保障数据安全,提供定制化服务与专业支持,满足内网需求企业的要求。
|
11月前
|
存储 监控 druid
Druid、ClickHouse、Doris、StarRocks 的区别与分析
本文对比了 Druid、ClickHouse、Doris 和 StarRocks 四款大数据分析引擎。它们均为 OLAP 引擎,采用列式存储和分布式架构,适用于海量数据分析。Druid 擅长实时分析与高并发查询;ClickHouse 以超高性能著称,适合复杂查询;Doris 提供易用的 SQL 接口,性能均衡;StarRocks 则以其极速查询和实时更新能力脱颖而出。各引擎在数据模型、查询性能、数据更新和存储方面存在差异,适用于不同的业务场景。选择时需根据具体需求综合考虑。
5368 20
|
SQL Java 数据库连接
详解Mybatis之自动映射 & 自定义映射问题(上)
详解Mybatis之自动映射 & 自定义映射问题(上)
|
Prometheus 监控 Cloud Native
Prometheus监控Spring Boot应用,自定义应用监控指标
Prometheus监控Spring Boot应用,自定义应用监控指标
718 0
Prometheus监控Spring Boot应用,自定义应用监控指标
|
XML Java 测试技术
【SpringBoot】基于 Maven 的 pom.xml 配置详解
【SpringBoot】基于 Maven 的 pom.xml 配置详解
1990 0
【SpringBoot】基于 Maven 的 pom.xml 配置详解
最新版 MyBatisPlus 分页插件(直接拿来就可以用)
最新版 MyBatisPlus 分页插件(直接拿来就可以用)
833 0

热门文章

最新文章