在工程1中,创建服务提供接口和实现类
1)DemoService.java 文件
package love;
public interface DemoService {
String sayHello(String name);
}
2)DemoServiceImpl.java文件
package love;
public class DemoServiceImpl implements DemoService {
public String sayHello(String name) {
return "Hello " + name;
}
}
3) Lover.java文件
package love;
import java.io.IOException;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class Lover {
public static void main(String[] args) throws IOException {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
new String[] {"META/spring/dubbo-demo-provider.xml"});
context.start();
// press any key to exit
System.in.read();
}
}
4)dubbo-spring服务配置文件META/spring/dubbo-demo-provider.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">