SpringBoot+MyBatis使用Hessian遠程服務通信

一、遠程項目配置spring

注:@Bean(name ="/") lua

@Autowired
private DryingService dryingService;
@Autowired
private EvaluateScoreService evaluateScoreService;
@Bean(name = "/dryingService")
public HessianServiceExporter dryingService(){
    HessianServiceExporter exporter = new HessianServiceExporter();
    exporter.setService(dryingService);
    exporter.setServiceInterface(DryingService.class);
    return exporter;
}

@Bean(name = "/evaluateScoreService")
public HessianServiceExporter evaluateScoreService(){
    HessianServiceExporter exporter = new HessianServiceExporter();
    exporter.setService(evaluateScoreService);
    exporter.setServiceInterface(EvaluateScoreService.class);
    return exporter;

}

二、本地項目配置文件url

service.url=http://localhost:8001
service.readTimeout=10000
service.connectTimeout=3000

三、本地項目spring-hessian.xmlxml

<bean id="evaluateScoreService" class="org.springframework.remoting.caucho.HessianProxyFactoryBean">
   <property name="serviceUrl" value="${service.url}/evaluateScoreService" />
   <property name="serviceInterface" value="com.service.EvaluateScoreService" />
   <property name="overloadEnabled" value="true"/>
   <property name="proxyFactory">
      <bean class="com.caucho.hessian.client.HessianProxyFactory">
         <property name="readTimeout" value="${service.readTimeout}" />
         <property name="connectTimeout" value="${service.connectTimeout}" />
      </bean>
   </property>
</bean>

3.配置rem

<bean id="evaluateScoreService" class="org.springframework.remoting.caucho.HessianProxyFactoryBean"> <property name="serviceUrl" value="${service.url}/evaluateScoreService" /> <property name="serviceInterface" value="com.service.EvaluateScoreService" /> <property name="overloadEnabled" value="true"/> <property name="proxyFactory"> <bean class="com.caucho.hessian.client.HessianProxyFactory"> <property name="readTimeout" value="${service.readTimeout}" /> <property name="connectTimeout" value="${service.connectTimeout}" /> </bean> </property> </bean>
相關文章
相關標籤/搜索