vertx web处体验+maven打包

Wesley13
• 阅读 649

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
         xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <modelVersion>4.0.0</modelVersion>
    <groupId>net.loyin.study</groupId>
    <artifactId>vertx</artifactId>
    <version>1.0-SNAPSHOT</version>
    <properties>
        <vertx.version>3.8.1</vertx.version>
    </properties>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>io.vertx</groupId>
                <artifactId>vertx-stack-depchain</artifactId>
                <version>${vertx.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>io.vertx</groupId>
                <artifactId>vertx-stack-depchain</artifactId>
                <version>${vertx.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>io.vertx</groupId>
            <artifactId>vertx-core</artifactId>
            <version>${vertx.version}</version>
        </dependency>
        <dependency>
            <groupId>io.vertx</groupId>
            <artifactId>vertx-web</artifactId>
            <version>${vertx.version}</version>
        </dependency>
        <dependency>
            <groupId>io.vertx</groupId>
            <artifactId>vertx-web</artifactId>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.1.0</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <transformers>
                                <transformer
                                        implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <manifestEntries>
                                        <main-class>io.vertx.core.Starter</main-class>
                                        <main-verticle>net.loyin.study.vertx.Application</main-verticle>
                                    </manifestEntries>
                                </transformer>
                            </transformers>
                            <artifactSet/>
                            <!--              <outputFile>${project.build.directory}/${project.artifactId}-${project.version}-fat.jar</outputFile>-->
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.2</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <profiles>
        <profile>
            <id>jdk18</id>
            <activation>
                <activeByDefault>true</activeByDefault>
                <jdk>1.8</jdk>
            </activation>
            <properties>
                <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
                <maven.compiler.source>1.8</maven.compiler.source>
                <maven.compiler.target>1.8</maven.compiler.target>
            </properties>
        </profile>
    </profiles>
</project>

启动类:

package net.loyin.study.vertx;

import io.vertx.core.AbstractVerticle;
import io.vertx.core.Vertx;
import io.vertx.ext.web.Router;

public class Application extends AbstractVerticle {

    public static void main(String[] args){
        Vertx vertx=Vertx.vertx();
        vertx.deployVerticle(new Application());
    }
    @Override
    public void start(){
        Router router=Router.router(vertx);
        router.route().handler(routingContext->{
            routingContext.response().putHeader("content-type", "text/html").end("Hello World!");
        });
        vertx.createHttpServer().requestHandler(router).listen(8800);
    }
}

Dockerfile

FROM java:8
VOLUME /tmp
ADD ./target/vertx-1.0-SNAPSHOT.jar app.jar
RUN bash -c 'touch /app.jar'
EXPOSE 8800
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","app.jar"]
点赞
收藏
评论区
推荐文章
blmius blmius
2年前
MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1
文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s
执键写春秋 执键写春秋
2年前
基于Maven工程下的MyBatis框架+MySQL+连接池的数据查询操作
具体操作项目结构引入项目依赖pom.xml<?xmlversion"1.0"encoding"UTF8"?<projectxmlns"http://maven.apache.org/POM/4.0.0"xmlns:xsi"http://www.w3.org/2001/XMLSchemainstance"xsi
Wesley13 Wesley13
2年前
java代码自动下载Spring Boot用户手册
本示例演示SpringBoot1.5.9.RELEASE版本的用户手册下载pom.xml<?xmlversion"1.0"encoding"UTF8"?<projectxmlns"http://maven.apache.org/POM/4.0.0"xmlns:xsi"http://w
Easter79 Easter79
2年前
springboot2.1整合mybatis
1:添加依赖<?xmlversion"1.0"encoding"UTF8"?<projectxmlns"http://maven.apache.org/POM/4.0.0"xmlns:xsi"http://www.w3.org/2001/XMLSchemainstance"xsi
Stella981 Stella981
2年前
Flink+Kafka整合的实例
FlinkKafka整合实例1.使用工具IntelligIDEA新建一个maven项目,为项目命名为kafka01。2.我的pom.xml文件配置如下。<?xmlversion"1.0"encoding"UTF8"?<projectxmlns"http://maven.apache.org/POM/4
Stella981 Stella981
2年前
Android蓝牙连接汽车OBD设备
//设备连接public class BluetoothConnect implements Runnable {    private static final UUID CONNECT_UUID  UUID.fromString("0000110100001000800000805F9B34FB");
Stella981 Stella981
2年前
SpringBoot2.1.6 + Shiro1.4.1 + Thymeleaf + Jpa整合练习
  首先,添加maven依赖,完整的pom文件如下:1<?xmlversion"1.0"encoding"UTF8"?2<projectxmlns"http://maven.apache.org/POM/4.0.0"xmlns:xsi"http://www.w3.org/2001/XMLSchema
Easter79 Easter79
2年前
SpringBoot2.1.6 + Shiro1.4.1 + Thymeleaf + Jpa整合练习
  首先,添加maven依赖,完整的pom文件如下:1<?xmlversion"1.0"encoding"UTF8"?2<projectxmlns"http://maven.apache.org/POM/4.0.0"xmlns:xsi"http://www.w3.org/2001/XMLSchema
Stella981 Stella981
2年前
SpringBoot——小试牛刀三阶段
21.SpringBoot的父级依赖1)创建父级工程pom.xml2)在父级工程里创建子module,pom.xml如下<?xml version"1.0" encoding"UTF8"?<project xmlns"http://maven.apache.org/POM/4.0.
Easter79 Easter79
2年前
SpringBoot——小试牛刀三阶段
21.SpringBoot的父级依赖1)创建父级工程pom.xml2)在父级工程里创建子module,pom.xml如下<?xml version"1.0" encoding"UTF8"?<project xmlns"http://maven.apache.org/POM/4.0.