为 spring 设置默认代理模式

Set default proxyMode for spring

要序列化我的 spring 网络应用程序的会话,我必须更改我的注释

@Controller
@Scope("request")

@Controller
@Scope(value = "request", proxyMode = ScopedProxyMode.TARGET_CLASS)

是否可以更改 applicationContext.xml 中的默认代理模式?

我在这个问题上迟到了,但对其他人仍然有用。

您也可以在 XML 中设置默认代理模式。

<beans>
    <context:component-scan base-package="org.example" scoped-proxy="interfaces"/>
</beans>

您可以根据需要更改 scoped-proxy 属性的值。

这也可以在 spring 引导应用程序中使用注释来完成。

@SpringBootApplication
@ComponentScan(basePackages = "org.example", scopedProxy = ScopedProxyMode.TARGET_CLASS)
public class SpringBootApplication {

    public static void main(String[] args) {
        SpringApplication.run(SpringBootHelloWorldApplication.class, args);
    }
}

https://docs.spring.io/spring-framework/docs/current/reference/html/core.html#beans-scanning-scope-resolver