为spring设置默认的proxyMode

要序列化我的spring Web应用程序的会话,我必须从更改批注

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

   val layoutManagersituation = GridLayoutManager(this,3) layoutManagersituation.spanSizeLookup = object : SpanSizeLookup() { override fun getSpanSize(position: Int): Int { return 3 - position % 3 } }

是否可以更改applicationContext.xml中的默认proxyMode?​​ p>

iCMS 回答:为spring设置默认的proxyMode

我在这个问题上迟到了,但是对其他人还是有用的。

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

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

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

这也可以在Spring Boot应用程序中使用批注来完成。

@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

本文链接:https://www.f2er.com/1672387.html

大家都在问