发表于: 2017-03-10 23:19:22

1 1529


今天完成的事情:完成了springMVC-RMI的demo,将学员系统的service拆分
明天计划的事情:将web拆出来,配置两个service进行测试
遇到的问题:在service里面添加第二个实现类的时候报错了(有思路了还没解决)
收获:主要还是理解RMI这种思想:

前面的基础师兄的总结非常好了http://www.jnshu.com/daily/7829?uid=3933

          这是一种分模块的思想,分成了service和web,在拆分的时候有个问题,model是放到server还是放到web里面,实际是,service和web都会用到model,所以这时候就需要将公共的类单独放一个模块。

在service.xml中添加

<bean id="studentServiceExporter" class="org.springframework.remoting.rmi.RmiServiceExporter">
   <property name="serviceName" value="StudentService"/>
   <property name="service" ref="studentService"/>
   <property name="serviceInterface" value="com.ptteng.service.StudentService"/>
   <property name="registryPort" value="8001"/>
   <property name="servicePort" value="8002"/>
</bean>
<bean id="studentService" class="com.ptteng.serviceImpl.StudentServiceImpl"></bean>

在web里面添加

<bean id="studentService" class="org.springframework.remoting.rmi.RmiProxyFactoryBean">
   <property name="serviceUrl" value="rmi://localhost:8001/StudentService"/>
   <property name="serviceInterface" value="com.ptteng.service.StudentService"/>
</bean>

启动server

public class StartServer {

public static void main(String[] args){
ApplicationContext context = new ClassPathXmlApplicationContext("classpath:service.xml");
}

这样在web就可以运行了




返回列表 返回列表
评论

    分享到