gpt4 book ai didi

spring - 资源不适用于范围原型(prototype)?

转载 作者:行者123 更新时间:2023-12-01 15:48:41 24 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
@Resource vs @Autowired

我用 @Scope("request") 定义了一个 Spring @Controller 并使用 @Resource 来定义一个服务 bean使用 @Scope("prototype"),但是在每次重新加载页面时,我总是获得相同的服务 bean 实例。

我发现将 @Resource 更改为 @Autowired 实际上以我期望的方式工作,并且每次重新加载页面时我都会获得一个新的服务 bean 实例.

这是预期的行为吗?我是否缺少对 @Resource@Autowired 之间区别的理解?

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