这几天呕血封装,终于把Event Bus封装成人能用的样子了
如何使用
我们看下vert.x-create项目如何使用之
DemoController.java
package wanke.com.controller;
import wanke.com.common.annotion.Controller;
import wanke.com.common.annotion.RequestMapping;
import wanke.com.common.msghandle.WrapMsg;
import java.util.HashMap;
import java.util.Map;
@Controller
@RequestMapping("device")
public class DemoController {
@RequestMapping("getdevice")
public Map get(WrapMsg msg){
//获取传参
Map body = msg.body();
//返回结果
HashMap data = new HashMap();
data.put("a","1");
return data;
}
}
application.properties
#proto,json,flat
transfer.data.format=proto
#本机局域网IP
transfer.data.ip=192.168.2.112
#Controller所在目录
vert.x.controller=wanke.com.controller
VertXApplication.java
package wanke.com;
import wanke.com.common.starter.AppCluster;
public class VertXApplication {
public static void main(String[] args) {
new AppCluster().main(args);
}
}
而做到这些只需要在本maven模块化工程中新建一个模块
引入pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>vertx-root</artifactId>
<groupId>org.example</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>vert.x-create</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>vert.x-create</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>