tars支持spring

和普通tars HelloWord 项目相比,客户端完全一样,服务端两个地方不一样

依赖

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

<dependency>
            <groupId>com.tencent.tars</groupId>
            <artifactId>tars-spring</artifactId>
            <version>1.4.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"/>

猜你喜欢

转载自www.cnblogs.com/huanggy/p/9257926.html
今日推荐