spring-ioc

Circular dependency in Spring injection - Is this bad design?

房东的猫 提交于 2021-01-27 13:40:39
问题 I am stuck with following issue : I am trying to create beans as follows: @Bean public abc createABC() { return new ABC(--, def(),--); } ` @Bean public DEF def() { return new DEF(--, createABC(),-- } Any suggestions to get around this problem without chaging to setter based injection. Is it the indicative of bad design? In my situation this dependency is must. Please provide your viewpoints on this 回答1: it the indicative of bad design? Absolutely. If ABC depends on DEF and DEF depends on ABC

Circular dependency in Spring injection - Is this bad design?

淺唱寂寞╮ 提交于 2021-01-27 13:25:56
问题 I am stuck with following issue : I am trying to create beans as follows: @Bean public abc createABC() { return new ABC(--, def(),--); } ` @Bean public DEF def() { return new DEF(--, createABC(),-- } Any suggestions to get around this problem without chaging to setter based injection. Is it the indicative of bad design? In my situation this dependency is must. Please provide your viewpoints on this 回答1: it the indicative of bad design? Absolutely. If ABC depends on DEF and DEF depends on ABC

Spring Boot: autowire beans from library project

元气小坏坏 提交于 2020-04-05 09:13:37
问题 I'm struggling to autowire beans from my custom library, imported with gradle. after reading couple of similar topics I am still unable to find solution. I have Spring Boot project that depends on other project(my custom library with Components, Repositories etc...). This library is a Spring non-runnable jar, that consists primarily from domain Entities and Repositories. It doesn't have runnable Application.class and any properties... When I starting the application I can see that My

Spring Boot: autowire beans from library project

我们两清 提交于 2020-04-05 09:12:10
问题 I'm struggling to autowire beans from my custom library, imported with gradle. after reading couple of similar topics I am still unable to find solution. I have Spring Boot project that depends on other project(my custom library with Components, Repositories etc...). This library is a Spring non-runnable jar, that consists primarily from domain Entities and Repositories. It doesn't have runnable Application.class and any properties... When I starting the application I can see that My

Spring Boot: autowire beans from library project

ⅰ亾dé卋堺 提交于 2020-04-05 09:11:31
问题 I'm struggling to autowire beans from my custom library, imported with gradle. after reading couple of similar topics I am still unable to find solution. I have Spring Boot project that depends on other project(my custom library with Components, Repositories etc...). This library is a Spring non-runnable jar, that consists primarily from domain Entities and Repositories. It doesn't have runnable Application.class and any properties... When I starting the application I can see that My

spring boot @Autowired a bean from another module

随声附和 提交于 2020-01-13 01:26:12
问题 My question is how can i add a package to my list of component to scan @ComponentScan(basePackages = {"io.swagger", "com.company.project", like add it here }), but this package is in another module in my project, here is the structure of my project : springbootProject (maven project)/ module1(mavenProject, com.company.module1) pom1.xml module2(mavenProject, com.company.module2) pom2.xml pom.xml in module 2 i have my main (@SpringbootAplication) where i want to @Autowired myRepository witch is

How to create a bean by type in Spring?

旧巷老猫 提交于 2019-12-24 08:19:08
问题 In my ApplicationContext I have several Beans being created the same style. So I have a lot of dublicated code writing a FactoryBean for each of this beans. Those beans have a common ground, implementing all one special interface. I would like to move all that bean creation to one factory. That one would have to provide a methode like this <T extends CommonInterface> T createInstance(Class<T> clazz); There I could implement all the instantiation necessary to create one of my special beans. My

Spring dependency issue - no matching editors or conversion strategy found

吃可爱长大的小学妹 提交于 2019-12-23 09:14:55
问题 I have a web application which fails while deployment. I get following error: Aug 8, 2014 7:00:21 PM org.springframework.web.context.ContextLoader initWebApplicationContext SEVERE: Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.filterChains': Cannot resolve reference to bean 'org.springframework.security.web.DefaultSecurityFilterChain#2' while setting bean property 'sourceList' with key [2];

How to check for Request Scope availability in Spring?

元气小坏坏 提交于 2019-12-21 07:30:07
问题 I'm trying to setup some code that will behave one way if spring's request scope is available, and another way if said scope is not available. The application in question is a web app, but there are some JMX triggers and scheduled tasks (i.e. Quartz) that also trigger invocations. E.g. /** * This class is a spring-managed singleton */ @Named class MySingletonBean{ /** * This bean is always request scoped */ @Inject private MyRequestScopedBean myRequestScopedBean; /* can be invoked either as

How to check for Request Scope availability in Spring?

拥有回忆 提交于 2019-12-21 07:30:06
问题 I'm trying to setup some code that will behave one way if spring's request scope is available, and another way if said scope is not available. The application in question is a web app, but there are some JMX triggers and scheduled tasks (i.e. Quartz) that also trigger invocations. E.g. /** * This class is a spring-managed singleton */ @Named class MySingletonBean{ /** * This bean is always request scoped */ @Inject private MyRequestScopedBean myRequestScopedBean; /* can be invoked either as