草庐IT

prototype-chain

全部标签

java - 在 Spring 运行时注册 bean(prototype)

只需要社区评估的东西。以下是一段代码,它是一个创建特定类型实例的简单工厂。该方法会将上下文中的bean注册为原型(prototype)并返回实例。这是我第一次在运行时配置bean。您能评价一下并提供反馈吗?提前谢谢你。packageau.com.flexcontacts.flexoperations;importorg.springframework.beans.BeansException;importorg.springframework.beans.factory.config.BeanDefinition;importorg.springframework.beans.fact

java - Spring 原型(prototype) bean 与单例 bean 和依赖注入(inject)相结合。是否有一种仅用于配置的方法?

我有一个单例bean,每次调用函数时都需要返回对不同(新)原型(prototype)bean的引用。我能想到的唯一方法是通过调用其getBean()方法以编程方式从BeanFactory/ApplicatioContext检索一个新的原型(prototype)bean实例。代码示例将遵循...有没有更好的方法来做到这一点?希望只能通过配置?(就个人而言,我怀疑有......)publicclassProtoBean{....}publicclassSingletonBean{privateBeanFactoryfactory;publicProtoBeandispense(){retu

spring - 为引用 session bean/原型(prototype) bean 的单例 bean 创建了多少个实例

我对下面提到的场景中使用SpringFramework时会创建的实例数量有疑问:bean配置是这样的or默认情况下,bean"a"有singletonscope.所以有一个单例bean引用具有session范围或原型(prototype)范围的bean。在这种情况下,如果有2个同时向应用程序发出请求,那么将创建多少个A实例和多少个B实例?如果有人能解释这是如何工作的,那将会有很大帮助。谢谢,迪维亚 最佳答案 单例范围当bean是singleton,将只管理bean的一个共享实例,并且所有对具有与该bean定义匹配的id或ids的be

java - 原型(prototype) Bean 没有按预期 Autowiring

TestController.java@RestControllerpublicclassTestController{@AutowiredprivateTestClasstestClass;@RequestMapping(value="/test",method=RequestMethod.GET)publicvoidtestThread(HttpServletResponseresponse)throwsException{testClass.doSomething();}}TestClass.java@Component@Scope("prototype")publicclass

java - 使用注释创建原型(prototype)范围的 Spring bean?

是否可以转换以下XMLconfiguration到基于注释的?我正在使用Spring2.5.6. 最佳答案 您可以使用@Scope(value=ConfigurableBeanFactory.SCOPE_PROTOTYPE)注释。@Service@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)publicclassCustomerService{//...}SpringAPIDocs.Exampleofthemapping.Scopeannotationreference.

spring - 单例和原型(prototype) bean 有什么区别?

我是Spring的新手,我读到了这个:BasicallyabeanhasscopeswhichdefinestheirexistenceontheapplicationSingleton:meanssinglebeandefinitiontoasingleobjectinstanceperSpringIOCcontainer.Prototype:meansasinglebeandefinitiontoanynumberofobjectinstances.那么什么是“对象实例”。 最佳答案 原型(prototype)范围=每次注入(i

spring - spring 3 MVC 应用程序是否有 maven 2 原型(prototype)?

我正在试验spring3MVC框架。因为我使用maven2来管理我的项目,所以我正在寻找一个原型(prototype)来创建一个spring3MVC应用程序。 最佳答案 您可以使用STS(springtoolsuite)一个新的springMVC模板项目使用spring3创建一个工作应用程序。或者您可以使用SpringRoo为您的项目奠定工作基础。 关于spring-spring3MVC应用程序是否有maven2原型(prototype)?,我们在StackOverflow上找到一个类似

Wildfly 上的 Spring Security : error while executing the filter chain

我正在尝试整合SpringSecuritySAMLExtension与SpringBoot。关于这件事,我确实开发了一个完整的示例应用程序。其源代码可在GitHub上获得:spring-boot-saml-integrationonGitHub通过将其作为SpringBoot应用程序运行(针对SDK内置应用程序服务器运行),WebApp可以正常工作。很遗憾,同样的AuthN过程在Undertow/WildFly上根本不起作用。根据日志,IdP实际上执行了AuthN过程:我自定义的UserDetails实现的指令被正确执行。尽管有执行流程,但Spring不会为当前用户设置和保留权限。@C

docker - 运行 docker 容器 : iptables: No chain/target/match by that name

我正在尝试运行容器,但遇到以下问题:Errorresponsefromdaemon:Cannotstartcontainerb005715c40ea7d5821b15c44f5b7f902d4b39da7c83468f3e5d7c042e5fe3fbd:iptablesfailed:iptables--wait-tfilter-ADOCKER!-idocker0-odocker0-ptcp-d172.17.0.43--dport80-jACCEPT:iptables:Nochain/target/matchbythatname.(exitstatus1)这是我使用的命令:dockerr

mongodb - Zend Framework 2 + Doctrine ODM, "The Class was not found in the chain configured namespaces"错误?

在设置ZF2+ODM时,我收到以下错误:Theclass'Application\Document\User'wasnotfoundinthechainconfigurednamespaces目前的设置如下:ZF2稳定,通过composer.phar与composer.json内容安装的学说ODM{"name":"zendframework/skeleton-application","description":"SkeletonApplicationforZF2","license":"BSD-3-Clause","keywords":["framework","zf2"],"hom