未验证 提交 6c6acf92 编写于 作者: S SnailClimb 提交者: GitHub

Merge pull request #15 from busysha/master

[feat] server test via annotation
import github.javaguide.HelloService;
import github.javaguide.annotation.RpcScan;
import github.javaguide.entity.RpcServiceProperties;
import github.javaguide.remoting.transport.netty.server.NettyServer;
import github.javaguide.serviceimpl.HelloServiceImpl2;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
/**
......@@ -11,17 +8,12 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext
* @author shuang.kou
* @createTime 2020年05月10日 07:25:00
*/
@RpcScan(basePackage = {"github.javaguide.serviceimpl"})
@RpcScan(basePackage = {"github.javaguide"})
public class NettyServerMain {
public static void main(String[] args) {
// Register service via annotation
new AnnotationConfigApplicationContext(NettyServerMain.class);
NettyServer nettyServer = new NettyServer();
// Register service manually
HelloService helloService2 = new HelloServiceImpl2();
RpcServiceProperties rpcServiceProperties = RpcServiceProperties.builder()
.group("test2").version("version2").build();
nettyServer.registerService(helloService2, rpcServiceProperties);
AnnotationConfigApplicationContext applicationContext=new AnnotationConfigApplicationContext(NettyServerMain.class);
NettyServer nettyServer = (NettyServer) applicationContext.getBean("nettyServer");
nettyServer.start();
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册