App.java
package com.adley;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.Vertx;
import io.vertx.core.http.HttpServer;
public class App extends AbstractVerticle {
public static void main(String[] args) {
System.out.println("hello vertx");
Vertx.vertx().deployVerticle(new App());
}
public void start() {
HttpServer server = vertx.createHttpServer().requestHandler(req -> {
req.response()
.putHeader("content-type", "text/plain")
.end("hello Vert.x");
});
server.listen(9090);
System.out.printf("server is running at PORT: %d ...", 9090);
}
}
plugins {
id 'java'
id 'application'
id 'com.github.johnrengelman.shadow' version '7.0.0'
}
group 'com.adley'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
}
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
implementation 'io.vertx:vertx-core:4.3.3'
}
test {
useJUnitPlatform()
}
def launcherClassName = 'io.vertx.core.Launcher'
def mainVerticleName = 'com.adley.App'
application {
mainClass = mainVerticleName
}
shadowJar {
classifier = 'fat'
manifest{
attributes 'Main-Verticle': launcherClassName
// attributes 'Main-Verticle': mainVerticleName
}
}
jar {
archivesBaseName = 'vertx-demo'//基本的文件名
archiveVersion = '0.0.1' //版本
manifest { //配置jar文件的manifest
// attributes(
// "Manifest-Version": 1.0,
// 'Main-Class': 'com.adley.App' //指定main方法所在的文件
// )
attributes 'Main-Verticle': mainVerticleName
}
}