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
0
votes
2 answers

Invoke another bean's method in @PostConstruct raised a null pointer ex

I am using Spring4. There are three beans:bean1 and bean2 and bean3,and in my bean1's @PostConstruct method,i invoke bean2's method,this method of bean2 will invoke bean3's method,and i got a NPE, beacuse method in bean2 is invoked, bean3 hasn't…
zysaaa
  • 1,777
  • 2
  • 8
  • 19
0
votes
2 answers

How to extend default bean annotated with @ConditionalOnMissingBean?

I've looked at this question to see how "default" beans are implemented in Spring. There is a bean in the parent module of my project that is annotated with @ConditionalOnMissingBean. I would like to take this bean and extend it's functionality…
Mario Ishac
  • 5,060
  • 3
  • 21
  • 52
0
votes
2 answers

How to configure spring-ioc dependency Injection in a personal way?

I'm currently working on a web application using Angular 7 for front-end, spring-boot for back-end (in which I'm developing a restful web service). I'm using @Autowired annotation to inject my services into each other and my rest controller. The…
0
votes
1 answer

how to get bean scope on spring?

I have the following class: public class ServiceFactory { private ServiceFactory() { } public static T loadService(Class klass) { ApplicationContext applicationContext =…
Thiago Sayão
  • 2,197
  • 3
  • 27
  • 41
0
votes
0 answers

@Autowired Bean from External Package fails

I have a Java (Maven) pkg with an interface (IHelloWorld) and implementation (HelloWorld) I have confirmed that I am able to consume the package with and without Spring IoC, but app is crashing when I try to use auto-wiring What am I doing…
Jason
  • 3,844
  • 1
  • 21
  • 40
0
votes
2 answers

How to pass a String (Non managed bean) to a managed bean

I have a spring batch job. There is a step that is calling the reader method. STEP @Bean public Step myStep(FlatFileItemWriter writer, Processor processor, @Value("${com.tableName}") String myTableName) { return…
Andy
  • 5,433
  • 6
  • 31
  • 38
0
votes
0 answers

How to get bean from spring IOC container which is running on another JVM?

I have multi-module application consider Module-A and Module-B that runs two IOC containers IOC-A and IOC-B respectively. I am quite beginner to multi-module architecture. As per my assumption, both modules runs on different JVMs. I am using Spring…
0
votes
2 answers

Replace Private Method of Spring Bean

i have requirement to replace private method of spring bean, can i achieve through spring replace. My Code : Replacer Class : public class PrivateCarRep extends Car implements MethodReplacer{ @Override public Object reimplement(Object obj,…
0
votes
1 answer

In a Spring service, should I set null or empty lists used in the end of a method to save memory?

I am using spring boot (generated by JHipster) with some services that are using a List as field. I was wondering wether I should empty or nullify this list at the end of the methods that use it. Is there any impact on JVM memory ? Considering this…
tacou_st
  • 109
  • 1
  • 9
0
votes
3 answers

Spring bean property set using xml configuration from other bean property

I have two bean classes like below package com.abc; public class Employee{ private String id; private String name; //setters & getters } and package com.cda; public class EmployeeDTO{ private String id; private String name; //setters &…
RAJESHPODDER007
  • 733
  • 1
  • 8
  • 14
0
votes
0 answers

Spring dependency Autowiring

I have a Facade for the persistence submodule exposed through the @Service annotation: @EnableMongoRepositories @Service public class MongoFacade { @Autowired private ShopsRepository shopsRepository; public List
0
votes
1 answer

Override default implementation of list or other collections in spring xml configuration file

I observed that the default implementation of list in spring xml is ArrayList. I tried:
0
votes
1 answer

Loading bean definitions from xml after creating ClassPathXmlApplicationContext object

I was practicing to use ClassPathXmlApplicationContext. One question that strike me is that, is there any way to load the bean definitions from xml after creating the ClassPathXmlApplicationContext object. I am trying something…
0
votes
1 answer

How to define an xml-configuration spring bean that is the result of a call to an enum's instance?

I have an enum (this is kotlin, but it doesn't matter, could be Java too) enum class AnEnum { A_VALUE { override fun aMethod(arg: ArgClass): AClass { //... } }; abstract fun aMethod(arg: ArgClass): AClass } I need a bean in a…
DPM
  • 1,960
  • 3
  • 26
  • 49
0
votes
1 answer

what is MethodInvokingFactoryBean in spring IOC?

I am new to the spring , and while going through this topic , I was unable to understand what is MethodInvokingFactoryBean 's exact use and when to use it ? can someone please help me here
sharady
  • 21
  • 6