Dubbo+Spring,调用jar包服务方法

public class SpringGetService {
private static ClassPathXmlApplicationContext context;
static {
context = new ClassPathXmlApplicationContext(new String[] { "spring.xml" });
context.start();
}
public static `Service` `getService`() {
return (`Service`) context.getBean("`Service`");
}
public static void main(String[] args) {
`Response`> res = `getService`().`method`("123456789");
JSONObject responeData = JSONObject.fromObject(JSON.toJSONString(res));
System.out.println(responeData);
System.out.println(res);
}

}

`xx`  中的字符需要替换成对应服务的相关信息


spring.xml


xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd http://code.alibabatech.com/schema/dubbo
        http://code.alibabatech.com/schema/dubbo/dubbo.xsd">






 

 


你可能感兴趣的:(Dubbo)