应用场景:B项目需要访问A项目的某些接口
一、A项目:
1.在pom.xml中添加hsf
<dependency>
<groupId>com.taobao.hsf</groupId>
<artifactId>hsf.app.spring</artifactId>
<version>2.1.0.8</version>
</dependency>
2.创建一个子项目api,只写需要向外提供的接口以及需要的bean:
package com.tiro.api;
public interface UserClientAPI {
List<User> listUser();
}
3.在另一个子项目biz中,在pom.xml中添加api项目,并实现api中的接口:
<dependency>
<groupId>com.tiro</groupId>
<artifactId>api</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
package com.tiro.api.impl;
public class UserClientAPIImpl implements UserClientAPI {
List<User> listUser(){
//实现代码
}
}
4.创建spring配置文件spring-hsf-provier.xml,添加接口到hsf服务中,配置文件如下:
<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd"
default-autowire="byName">
<bean id="userClientAPIImpl" class="com.tiro.api.impl.UserClientAPIImpl"/>
<bean id="useerClientAPIProvider" class="com.taobao.hsf.app.spring.util.HSFSpringProviderBean" init-method="init">
<property name="serviceInterface">
<value>com.tiro.api.UserClientAPI</value>
</property>
<property name="target">
<ref bean="userClientAPIImpl"/>
</property>
<property name="serviceName">
<value>userClientAPIService</value>
</property>
<property name="serviceVersion">
<value>1.0.0.daily</value>
</property>
</bean>
</beans>
5.在webx.xml中导入该配置文件:
<beans:import resource="spring-hsf-provider.xml" />
6. 将子项目api发布到中央仓库:
mvn deploy
7. 使用jerry运行项目,添加taobao-hsf.sar扩展。
二、项目B:
1.在pom.xml添加api项目:
<dependency>
<groupId>com.tiro</groupId>
<artifactId>api</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
2.创建spring配置文件spring-hsf-consume.xml,从hsf服务中获取接口,配置文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans default-autowire="byName">
<bean id="userClientAPI" class="com.taobao.hsf.app.spring.util.HSFSpringConsumerBean" init-method="init">
<property name="interfaceName" value="com.tiro.api.UserClientAPI" />
<property name="version">
<value>1.0.0.daily</value>
</property>
</bean>
</beans>
3.在webx.xml中导入该配置文件:
<beans:import resource="spring-hsf-consume.xml" />
4.这样你就可以在项目中直接使用userClientAPI接口了。
三、参考:
分享到:
相关推荐
淘宝的HSF框架,用户手册,有兴趣的人欢迎下载~内部文档哦~
HSF 官网Demo、IDEA 与 eclipse 开发环境说明;HSF,包结构等等
hsf框架所需工具包 taobao-hsf.sar 直接放入tomcat根目录tomcate/deploy/下即可
taobao-hsf安装包
自己公司用的HSF架构培训手册,当时还有阿里的人来培训我们,希望帮助到需要用的HSF技术的人
HSF 框架的原理讲解,主要包含了知识点:rpc,动态代理,HSF可以作为微服务的基础框架进行二次开发
Springboot+HSF分布式服务框架+EDAS注册中心,实现发布订阅模式
内部分享的hsf使用介绍文档(无涉密信息),有兴趣的同学可以看看
HSF物料风险等级评估及抽样检验规范.docx
EDAS中HSF方式启动服务入门文档,详细描述了EDAS中HSF方式的启动过程
SF全称为High-Speed Service Framework,旨在为淘宝应用提供一个分布式的服务框架,HSF从分布式应用层面以及统一的发布/调用方式层面为大家提供支持,从而可以很容易的开发分布式的应用以及提供戒使用公用功能模块,...
在组织内及其分包方和供应商处文件化所有元件或产品的制造,供应和维修控制过程 在采购所有的元件和/或使用的产品时,文件化供应商批准过程及HSF符合性控制过程 文件化所有元件或产品的生产过程的评审和批准的顺序,...
阿里云HSF用户开发指导手册 阿里云HSF用户开发指导手册
NULL 博文链接:https://arlenye.iteye.com/blog/2294835
HSF文件资料管理程序 1.0 目的: 确保绿色管理系统规定的文件、记录及资料能有效的制定、应用、储存及保管 并 能适时地取得正确有效的文件。 2.0 范围: 绿色管理系统规定之文件、记录及资料皆属之。 3.0 定义: 1. ...
https://www.nist.gov/srd/nist-special-database-19 里面的by_field 搬运(图片格式) 注意仅仅是 其中的一部分 hsf_0 hsf_1 (原文件中有hsf_0 --hsf_7) 每个hsf中有数字 字母 小写字母, 大写字母 ,每个数字和...
EDAS 生产者 消费者 api 齐全 环境配好既可以使用................................................................
HSF-1抑制HMGB1引起的炎症反应的机制,李杉珊,尹朝奇,目的 探讨热休克转录因子1抑制高迁移率族蛋白1引起炎症反应的机制。方法 HSF1质粒转染RAW264.7细胞,1μg/ml HMGB1刺激空白细胞,转染空质�
psftp windows bat... 使用使用构建工具构建的多个工程文件,且这些文件在linux的不同目录下。 配置文件config.txt 每行两列,每列使用\t(制表符)分隔,第一列是下载的本地目录,第二列是服务器上源文件的目录