小编Anv*_*han的帖子

mixins和继承有什么区别?

我试图在scala的上下文中理解Mixins.特别是我想知道继承概念和Mixins之间的区别.Wiki说mixins和inheritance的概念之间有重要的区别,因此我想理解它.

维基中Mixin的定义是:

mixin类充当父类,包含所需的功能.然后,子类可以继承或简单地重用此功能,但不能作为专业化的手段.通常,mixin会将所需的功能导出到子类,而不会创建严格的单个"是"关系.这里存在mixins和inheritance概念之间的重要区别,因为子类仍然可以继承父类的所有特性,但是,不必一定应用关于子元素"作为一种父类" 的语义.

在上面的定义中,我无法理解以粗体标出的语句.这是什么意思

  1. 子类可以在mixin中继承功能,但不能作为专业化的手段
  2. 在mixins中,子类继承了父类的所有特性,但是关于子元素的"语义",不一定要应用父类. - 孩子如何延伸父母而不一定是父母?有这样的例子吗?

提前感谢您对上述内容的任何澄清.

oop scala

17
推荐指数
2
解决办法
3828
查看次数

更好地理解错误:当前线程的作用域"会话"不活动

我一直在努力理解这个错误.我已经完成了与此相关的大部分问题,我不清楚,因为大多数问题都是如何解决的.我想了解错误是什么以及它为什么会出现.请帮助我理解如下:

  1. 为什么spring会查看范围"session"的当前线程?spring是否在线程上下文中存储了所有请求属性和会话属性?

2.我不一致地接受这个错误.如果这是一个问题,它应该一直都会出现.以下是我的代码段.

- 申请背景

<bean id="location" class="com.mindtree.ruc.cmn.utils.LoginLocation" scope="session">
        <aop:scoped-proxy/>
    </bean>
    <bean id="homePageRH" class="com.rsaame.pas.home.ui.HomePageRH">
        <property name="location" ref="location" />
    </bean>
Run Code Online (Sandbox Code Playgroud)

- web.xml

 <listener>
    <listener-class>
      org.springframework.web.context.request.RequestContextListener
    </listener-class>
  </listener>
Run Code Online (Sandbox Code Playgroud)

- 日志:

Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.rsaame.pas.dao.cmn.PASStoredProcedure]: Constructor threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.location': Scope 'session' is not active for the current thread; consider defining a scoped proxy for this bean if you intend to refer to it from a singleton; nested exception is …
Run Code Online (Sandbox Code Playgroud)

java spring

2
推荐指数
1
解决办法
8612
查看次数

标签 统计

java ×1

oop ×1

scala ×1

spring ×1