1, go to the official website to download Ali cloud Demo edas-app-demo.zip
2. Download Ali-Tomcat and Pandora, note the red font below
a) download ALI- the Tomcat, after saving the extract to the appropriate directory (eg: d: \ work \ tomcat \ ).
b) Download Pandora container, to save the contents of the above will extract the saved Ali -Tomcat deploy directory (d: Under \ work \ tomcat \ deploy)
3, download lightweight version EDAS (Download: https: //help.aliyun.com/document_detail/44163.html), and host configuration file
Open the host file, C: \ Windows \ System32 \ drivers \ etc, edit the last line, 192.168.1 .24 is the ip of your computer, the domain name is unique, fixed 192.168.1.24 jmenv.tbsite.net
4, cd to the bin directory edas-lite-configcenter, operating startup.bat
5, see the start time in local edas browser, localhost: 8080.
If a diamond appears, indicating a successful host configuration file, did not see the diamond, to see whether the host file configuration errors
6, open the idea, loaded edas-app-demo as a maven project.
1、使用aliTomcat 配置为: -Dfile.encoding=UTF-8 -Dpandora.location=D:\software\AliTomcat\taobao-tomcat-7.0.59\deploy\taobao-hsf.sar -Dhsf.server.ip=本机ip -Dhsf.server.port=12200 2、启动demo的两个应用: a)itemcenter #先启动服务提供者 b)detail #再启动消费者,否则报错
7、启动注意项
a)启动的时候一定要查看pandora是否启动,如图表示启动了
b)出现HSFServiceAddressNotFoundException错误,表明消费者没有连接上服务者,或者说服务者没有启动。查看服务者时候上线,可以再localhost:8080进行查看
com.taobao.hsf.exception.HSFServiceAddressNotFoundException: HSFServiceAddressNotFoundException- error message : [HSF-Consumer] can't find target service addresses, target serviceName:com.alibaba.edas.carshop.itemcenter.ItemService:1.0.0 Group:HSF ERR-CODE: [HSF-0001], Type: [BIZ], More: [http://edas.console.aliyun.com/code?faq=HSF-0001] at com.taobao.hsf.registry.RegistryInvocationHandler.invoke(RegistryInvocationHandler.java:173) at com.taobao.hsf.invocation.DelegateInvocationHandler.invoke(DelegateInvocationHandler.java:12) at com.taobao.hsf.remoting.service.LocalInvocationHandler.invoke(LocalInvocationHandler.java:99) at com.taobao.hsf.invocation.filter.RPCFilterBuilder$TailNode.invoke(RPCFilterBuilder.java:280) at com.taobao.hsf2dubbo.context.DubboRPCContextClientFilter.invoke(DubboRPCContextClientFilter.java:43) at com.taobao.hsf.invocation.filter.RPCFilterNode.invoke(RPCFilterNode.java:71) at com.taobao.hsf.context.RPCContextClientFilter.invoke(RPCContextClientFilter.java:31) at com.taobao.hsf.invocation.filter.RPCFilterNode.invoke(RPCFilterNode.java:71) at com.taobao.hsf.rpc.generic.GenericInvocationClientFilter.invoke(GenericInvocationClientFilter.java:59) at com.taobao.hsf.invocation.filter.RPCFilterNode.invoke(RPCFilterNode.java:71) at com.taobao.hsf.remoting.service.InvocationValidationFilter.invoke(InvocationValidationFilter.java:48) at com.taobao.hsf.invocation.filter.RPCFilterNode.invoke(RPCFilterNode.java:71) at com.taobao.hsf.plugins.spas.SpasClientFilter.invoke(SpasClientFilter.java:82) at com.taobao.hsf.invocation.filter.RPCFilterNode.invoke(RPCFilterNode.java:71) at com.taobao.hsf.plugins.eagleeye.EagleEyeClientFilter.invoke(EagleEyeClientFilter.java:76) at com.taobao.hsf.invocation.filter.RPCFilterNode.invoke(RPCFilterNode.java:71) at com.taobao.hsf.invocation.stats.InvocationStatsClientFilter.invoke(InvocationStatsClientFilter.java:45) at com.taobao.hsf.invocation.filter.RPCFilterNode.invoke(RPCFilterNode.java:71) at com.taobao.hsf.monitor.log.filter.MonitorLogClientFilter.invoke(MonitorLogClientFilter.java:51) at com.taobao.hsf.invocation.filter.RPCFilterNode.invoke(RPCFilterNode.java:71) at com.taobao.hsf.common.filter.CommonClientFilter.invoke(CommonClientFilter.java:26) at com.taobao.hsf.invocation.filter.RPCFilterNode.invoke(RPCFilterNode.java:71) at com.taobao.hsf.invocation.filter.RPCFilterBuilder$HeadNode.invoke(RPCFilterBuilder.java:246) at com.taobao.hsf.invocation.filter.FilterInvocationHandler.invoke(FilterInvocationHandler.java:28) at com.taobao.hsf.cluster.TestAddressInvocationHandler.invoke(TestAddressInvocationHandler.java:50) at com.taobao.hsf.remoting.service.AsyncInvocationHandler.invoke(AsyncInvocationHandler.java:44) at com.taobao.hsf.invocation.FutureInvocationHandler.invoke(FutureInvocationHandler.java:44) at com.taobao.hsf2dubbo.DubboAsyncInvocationHandler.invoke(DubboAsyncInvocationHandler.java:93) at com.taobao.hsf.invocation.AsyncToSyncInvocationHandler.invokeType(AsyncToSyncInvocationHandler.java:220) at com.taobao.hsf.invocation.AsyncToSyncInvocationHandler.invoke(AsyncToSyncInvocationHandler.java:46) at com.taobao.hsf.profiler.ProfilerSyncInvocationHandler.invoke(ProfilerSyncInvocationHandler.java:35) at com.taobao.hsf.rpc.client.ErrorLogSyncInvocationHandler.invoke(ErrorLogSyncInvocationHandler.java:47) at com.taobao.hsf2dubbo.DubboFilterSyncInvocationHandlerInterceptor.invoke(DubboFilterSyncInvocationHandlerInterceptor.java:76) at com.taobao.hsf.rpc.client.ClientConcurrencyLimiter.invoke(ClientConcurrencyLimiter.java:41) at com.taobao.hsf.InvocationUtil.invoke(InvocationUtil.java:43) at com.taobao.hsf.proxy.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:31) at com.taobao.hsf.proxy.JdkProxyFactory$JdkProxyInvocationHandler.invoke(JdkProxyFactory.java:99) at com.sun.proxy.$Proxy22.getItemById(Unknown Source) at com.alibaba.edas.carshop.detail.StartListener$1.run(StartListener.java:27) at java.lang.Thread.run(Thread.java:748)
8、服务提供者和消费者配置
a)假设存在一个服务提供者ItemService
其配置如下:
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:hsf="http://www.taobao.com/hsf" xmlns="http://www.springframework.org/schema/beans" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.taobao.com/hsf http://www.taobao.com/hsf/hsf.xsd" default-autowire="byName"> <bean id="itemService" class="com.alibaba.edas.carshop.itemcenter.ItemServiceImpl" /> <!-- 提供一个服务示例 --> <hsf:provider id="itemServiceProvider" interface="com.alibaba.edas.carshop.itemcenter.ItemService" ref="itemService" version="1.0.0"> </hsf:provider> </beans>
b)假设存在一个消费者detail,需要使用上述的服务ItemService
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:hsf="http://www.taobao.com/hsf" xmlns="http://www.springframework.org/schema/beans" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.taobao.com/hsf http://www.taobao.com/hsf/hsf.xsd" default-autowire="byName"> <!-- 消费一个服务示例 --> <hsf:consumer id="item" interface="com.alibaba.edas.carshop.itemcenter.ItemService" version="1.0.0"> </hsf:consumer> </beans>
记住:在需要使用别人的服务时,一定要先启动需要调用的服务,否则报错!!!