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();
            }
        });
    }
}
目录
相关文章
|
运维 算法 调度
系统授权license方案
软件系统设计关于授权时的一点见解
|
存储 Ubuntu C语言
Ubuntu 软件安装方法(入门必看)
Ubuntu 软件安装方法(入门必看)
1444 0
Ubuntu 软件安装方法(入门必看)
|
5月前
|
存储 前端开发 NoSQL
高并发场景下的订单幂等性设计:从重复支付到精准扣款的实战
跨境电商订单系统需解决重复提交导致的重复下单问题。本文详解幂等性原理与实践:通过唯一订单号+数据库索引、Redis幂等令牌(含Lua原子校验)、订单号复用及多服务协同等方案,兼顾可靠性与性能,核心在于唯一标识、状态记录与原子操作三要素。(239字)
334 0
|
11月前
|
存储 Java 测试技术
JavaWeb04-初识Maven
Maven是Java项目构建与依赖管理工具,基于POM模型,通过pom.xml统一配置项目信息、依赖及构建流程;支持自动下载jar包、标准化跨平台编译/测试/打包、统一目录结构,并集成JUnit单元测试,大幅提升开发效率与工程规范性。
555 5
|
Web App开发 移动开发 JavaScript
面试官:说一下script 标签中 defer(推迟) 和 async(异步) 的区别
面试官:说一下script 标签中 defer(推迟) 和 async(异步) 的区别
740 0
|
Ubuntu Linux 数据安全/隐私保护
Windows就是Linux:WSL带来全新Linux开发体验
Windows就是Linux:WSL带来全新Linux开发体验
defineProps和defineEmits
本文介绍了Vue 3中的`defineProps`和`defineEmits`函数的用法,其中`defineProps`用于声明组件的属性(props),以便从父组件接收数据,而`defineEmits`用于定义组件可以触发的自定义事件,从而实现子组件向父组件传递数据的功能。
|
块存储 芯片 内存技术
计算机组成原理(4)-----Cache的原理及相关知识点(1)
计算机组成原理(4)-----Cache的原理及相关知识点
2100 2