Questions tagged [spring-ioc]

The Spring IoC is a core component of the Spring Framework. It enforces the dependency injection pattern for beans, making them loosely coupled and allowing application developers to code with abstractions.

The Spring IoC (Inversion of Control) is a core component of the Spring Framework. It enforces the dependency injection pattern for beans, making them loosely coupled and allowing application developers to code with abstractions.

It is a process whereby objects define their dependencies only through constructor arguments, factory method arguments, and properties to be set on the object after it is constructed. The container then injects those dependencies when it creates the bean.

192 questions
1
vote
1 answer

Implement custom annotation in Spring

I want to implement an annotation which registers classes (not instances of classes) with a factory as soon as the application is started. I am using Spring Framework 4.2.7. Consider a system with a dashboard and multiple widgets. The dashboard has…
gdiquest
  • 125
  • 8
1
vote
4 answers

NotReadablePropertyException: Invalid property 'id' of bean class [java.util.LinkedHashMap]

I'm trying to create an abstract service in my springMVC application. My data flows* perfect through my layers, but my persistence (Abstraction), could not find a way to save/delete/update my database, these are the classes: abstract class…
davidwillianx
  • 391
  • 2
  • 5
  • 13
1
vote
2 answers

Combination of scope-proxy and parent

Hi I have the following short code : https://github.com/shmuel-buchnik/scope-issue I am getting the following error : "Invalid property 'targetBeanName' of bean class [C]: Bean property 'targetBeanName' is not writable or has an invalid setter…
1
vote
1 answer

List injection order in Spring IoC container

Suppose I'm injecting list of some beans: @Autowired List beans; What is default injection order in this situation? I know about Ordered interface and @Order annotation, I'm asking only about default behavior. What I've noticed is that…
Dmytro
  • 1,850
  • 3
  • 14
  • 20
1
vote
1 answer

What are all the @Configuration naming rules for beans?

I have some integration tests that are supposed to mock out one of many beans in my system. To do this, I have a @Configuration that looks like this: @Configuration public class MockContext { @Primary @Bean public RealBean realBean() { …
Daniel Kaplan
  • 62,768
  • 50
  • 234
  • 356
1
vote
0 answers

How to configure lazy loading JndiObjectFactoryBean for Java mail session

I have a requirement where my Spring JndiObjectFactoryBean has to do lazy lookup of Java mail session configured in my jetty server Following is the Mail session declaration in my jetty.xml
Dattatreya Kugve
  • 320
  • 1
  • 4
  • 21
1
vote
3 answers

Inject annotation based Bean into an xml based bean

My persistence configuration Class looks like bellow : @Configuration @EnableTransactionManagement public class PersistenceConfig { @Autowired private Environment env; // code here @Bean(name = "dataSource") public DataSource…
Abdelghani Roussi
  • 2,707
  • 2
  • 21
  • 39
1
vote
4 answers

What is exact meaning of Spring Singleton scope?

I defined two beans for a same class with different id names in applicationContext.xml. It working perfectly, so I got confused what is exact Spring singleton scope mean. I gone through some other similar questions in Stack Overflow. But I am not…
Sun
  • 3,444
  • 7
  • 53
  • 83
1
vote
1 answer

Is it still true that SpringJUnit4ClassRunner can't reliably call DisposableBean.destroy after tests

According to: https://jira.spring.io/browse/SPR-4103 SpringJUnit4ClassRunner won't always called DisposableBean.destroy after tests (*facepalm*!) -- due to implementation problems with JUnit. Is this still true? I'm creating tests in scala like…
user48956
  • 14,850
  • 19
  • 93
  • 154
1
vote
1 answer

AnnotationConfigApplicationContext.getBean returns a different bean, Spring

I have a problem that I have a ClassA needs RoomService to be injected, and it works fine that I find in ClassA, the roomService's id is the same. While for some reason, I need roomservice to create room instance based on some input param for me, so…
JaskeyLam
  • 15,405
  • 21
  • 114
  • 149
1
vote
3 answers

Class type injection in Spring xml vs java config

Class X{ Class object; public setObject( Class a ){....} } Interface B{} Interface C extends B {} I instantiate X like this, X x = new X(); x.setObject( C.class ); When i build the code it complains required Class found Class.…
broun
  • 2,483
  • 5
  • 40
  • 55
1
vote
1 answer

What's the use of @Component in spring?

Guice does not have a similar concept. For example, Guice can automatically inject any class with a default constructor without the need for any special class annotation. Why does spring have to know about every bean on startup? For the purposes of…
sha
  • 614
  • 6
  • 16
1
vote
1 answer

The event model of Spring

I'm new to Spring I found this information about limitations of event model of Spring: "It is not transactional. If an event is published, then an error occurs after treatment listeners, they can not be canceled. There there are no means for…
Zrom
  • 1,192
  • 11
  • 24
1
vote
2 answers

Write a spring bean with a constructor that contains a list of values from property file

Could you help me what the proper way of writing spring bean with parameter of list values which I get from .properties file.
Sergii Lisnychyi
  • 477
  • 4
  • 10
  • 16
1
vote
1 answer

Spring Controller Injected Properties Turn Null

I have a situation very similar to "Inject a file resource into Spring bean" I have a controller that uses some .jasper compiled files and I am declaring them as such //... @Controller public class InvoicingController { private Resource…
benashby
  • 468
  • 2
  • 11