spring 开发 Tars

和不使用 Spring 的 tars HelloWord 项目相比,客户端完全一样,服务端两个地方不一样

创建不使用 Spring 的 tars HelloWord 步骤: https://www.cnblogs.com/huanggy/p/9250160.html

依赖

在之前的基础上添加依赖 ---- spring 相关 jar 包

<dependency>
            <groupId>com.tencent.tars</groupId>
            <artifactId>tars-spring</artifactId>
            <version>1.6.0</version>
        </dependency>

暴露服务

1,servants.xml 更名为 servants-spring.xml ,这个文件就相当于 spring 的配置文件 applicationContext.xml ,在此可以集成 SSM 等

2,加入 xsd 

xmlns:tars="http://tars.tencent.com/schema/tars
http://tars.tencent.com/schema/tars http://tars.tencent.com/schema/tars/tars.xsd

3,配置服务

<!-- 配置实现类 bean -->
<bean id="HelloServantImpl" class="com.weipai.server.testapp.impl.HelloServantImpl" />
<!-- 暴露服务 -->
<tars:servant name="HelloObj" interface="com.weipai.server.testapp.HelloServant" ref="HelloServantImpl"/>

 

posted @ 2018-07-03 12:02  huanggy  阅读(313)  评论(0编辑  收藏  举报