gpt4 book ai didi

aop :scoped proxy的Spring JavaConfig

转载 作者:行者123 更新时间:2023-12-04 10:07:11 27 4
gpt4 key购买 nike

什么是 JavaConfig 等价物?

<!-- an HTTP Session-scoped bean exposed as a proxy
that acts as session storage.
-->
<bean id="checkOutCounter" class="org.brightworks.genesis.client.forms.CheckOutCounter" scope="session">
<!-- this next element effects the proxying of the surrounding bean -->
<aop:scoped-proxy/>
</bean>

尝试像这样声明它,但它仅充当单例
@Bean
public CheckOutCounter checkOutCounter(){
return new CheckOutCounter();
}

什么是上述 xml 配置的等价物?

最佳答案

对于组件初始化:

@Component
@Scope(value = "session", proxyMode = ScopedProxyMode.INTERFACES)

对于@Bean:
@Bean
@Scope(value="session", proxyMode = ScopedProxyMode.TARGET_CLASS)
public CheckOutCounter checkOutCounter(){
return new CheckOutCounter();
}

关于aop :scoped proxy的Spring JavaConfig,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29458473/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com