发表于: 2018-01-30 18:20:03

1 568


今日完成

1.完成spring和tuscany的整合

(1)将studentService服务配置在 springxml文件中。

    <sca:service name="StudentService1" type="lujing.service.StudentService" target="studentServiceImpl"/>

<import resource="spring/applicationContext-dao.xml"/>
<import resource="spring/applicationContext-service.xml"/>

(2)对应的composite文件

<composite
       xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
       xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
       targetNamespace="http://lujing.service"
       name="ScaDemo">

<component name="ScaDemo">
   <implementation.spring location="spring-tuscany.xml"></implementation.spring>

   <service name="StudentService1" >
       <tuscany:binding.rmi uri="rmi://127.0.0.1:8088/StudentService1"/>
   </service>
</component>

</composite>

这里说明一下

service的name与spring-tuscany.xml里面的name是一致的,。

2.客户端,在controller中写一个打开服务获得service的方法。

public StudentService getStudentService() {
try {
StudentService xx = (StudentService) Naming.lookup("//127.0.0.1:8088/StudentService1");
       System.out.println("连接成功........>>>>....");
       
       return xx;
   } catch (NotBoundException e) {
e.printStackTrace();
   } catch (MalformedURLException e) {
e.printStackTrace();
   } catch (RemoteException e) {
e.printStackTrace();
   }
return null;

}


接口中直接使用

StudentService studentService = this.getStudentService();

测试一下。就可以连上了

2.发布项目到tomcat上面。

遇到问题

今天用了s

1.无法导入properties的配置文件。(已解决)

spring3.05 与spring 4 的配置方法完全不一样了。4.0的版本可以将所有的配置文件写在一起。

<!-- 配置加载数据源文件 -->
<!--<context:property-placeholder location="classpath:db.properties" />-->
<bean id="propertiesConfigurer" class= "org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
  <property name="locations">
     <list>
        <value>
           classpath:properties/db.properties
</value>
        <value>
           classpath:properties/cos.properties
</value>
        <value>
           classpath:properties/redis.properties
</value>
     </list>
  </property>
</bean>

2.使用注解驱动后,报错

查看源码,发现

里面有一个校验的,需要到一个包。

<dependency>
 <groupId>org.hibernate</groupId>
 <artifactId>hibernate-validator</artifactId>
 <version>5.2.4.Final</version>
</dependency>

3.文件上传出错。竟然要单独加@requestparam,弄了好久啊。

4.参数绑定的问题,使用@pathvariable的区别。

4.3.12,一次申明之后,可以用对象去接收。

3.0.5,同样的写法是接收不到的。

5.打包出错,也是调试了好久,compostie竟然打包不进去。。。。。然后发现坑在pom文件里面。不加这个的话,java里面的xml都打包不进去。

明日计划

1.小课堂

2.任务9代码提交与整理。

收获

1.比较了好多spring3.0.5与4.3.12的区别。


返回列表 返回列表
评论

    分享到