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
3 answers

Is there a way to make some beans created by @Bean distinguishable?

This is an exotic use-case, so it requires some patience to understand and may require exotic solutions. The Context I'm making a library to be used with Spring that performs automatic actions upon specific bean instances present in the context,…
kaqqao
  • 12,984
  • 10
  • 64
  • 118
1
vote
1 answer

Spring Ioc Beans management

I have a question about spring IoC management. I created Bean in: @SpringBootApplication public class Application { public static void main(String[] args) {....} @Bean public XmlMapper xmlMapper() { return new XmlMapper(); …
1
vote
0 answers

Spring Autowire mechanics with plain XML configuration

I am trying to understand the various Spring bean configurations, and at the outset, trying the traditional XML way. Now I came to know for dependency injection,the "basic" methods are setter injection and constructor injection. Thus far, good. I…
CuriousMind
  • 8,301
  • 22
  • 65
  • 134
1
vote
3 answers

Spring Batch configure Multiple Readers/Processors/Writers for single JOB based on JobParameters

I have a spring batch application configured as per below link. https://spring.io/guides/gs/batch-processing/ Now I have to configure step in such a way that it has to take FlatFileItemReader if user input is file and JdbcPagingItemReader if the…
karthik
  • 773
  • 2
  • 11
  • 19
1
vote
2 answers

Call a bean on @PreDestroy

I' ve got two beans. Both have @PreDestroy methods. One of the beans must call in his @PreDestroy the second while the second is alive. How can I do this? I will provide a more detiled description of a problem. On my application shutdown I must…
goto1134
  • 107
  • 11
1
vote
2 answers

Autowired ApplicationContext has not method getBean

I have autowired ApplicationContext in my RestController class as I needed to create a prototyped bean for each of the request received. To create the bean I tried context.getBean(xx) but context has not getBean() method listed. Is there a way that…
1
vote
1 answer

Spring in a JavaFX application - how to property handle controller as dependency?

I have a JavaFX application that uses spring boot, exactly as described in this blog post: http://www.greggbolinger.com/let-spring-be-your-javafx-controller-factory/ I am using the FXML loader overriding the controller factory to use spring. The…
Thiago Sayão
  • 2,197
  • 3
  • 27
  • 41
1
vote
1 answer

java hibernate storing sql queries in xml file

I am trying to place all sql queries in xml file.I am using Spring boot and hibernate with native sqls Can someone provide me the example how to load and get the query string from xml file in spring boot and hibernate. I am using java based…
neha
  • 31
  • 5
1
vote
1 answer

@Value force startup validation

I have the following spring component. I would like to find a more elegant way of injecting the config value. @Component public class Clazz { @Value("${config.value.foo:#{null}}") public String foo; @PostConstruct public…
Liviu Stirb
  • 5,876
  • 3
  • 35
  • 40
1
vote
0 answers

How to Autowire Spring Beans without Application Context

I would like to be able to use a bean via auto-wiring and without having to directly use an ApplicationContext. Below is a dummy example of what I would like to be able to do. Configuration Class @Configuration public class CoffeeConfig { …
moonboy
  • 1,296
  • 4
  • 16
  • 29
1
vote
1 answer

How to inject bean in controller without annotation in spring mvc

I am developing spring mvc web application. I want to inject a bean class inside controller or service class but I don't want to use any type of annotation.
Santosh Pandey
  • 190
  • 1
  • 1
  • 10
1
vote
1 answer

How to resolve ambiguity in Spring constructor injection

I am trying to learn constructor injection using Spring 4.3. I am having class structure is stated below. @Component public class Student { private Address address; private City city; public Student(Address address, City city) { …
1
vote
4 answers

How to create a bean by type in Spring?

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…
mibutec
  • 2,929
  • 6
  • 27
  • 39
1
vote
1 answer

Use @Autowire in Jax-Ws with Spring Container

I have a Jax-Ws Metro project with Spring container. I cannot autowire a field inside SoapHandler. I tried everything from internet resources but no success. The field is always null. Field name is "paymentPortalService". My Handler class: public…
0bj3ct
  • 1,400
  • 4
  • 22
  • 51
1
vote
1 answer

AutoWiring with constructor, how IOC will select constructor among multiple constructor

I have three beans: Movie, Director, Hero Movie bean: public class Movie { private Director director; private String name; private Hero hero; public Movie(Director director, Hero hero) { System.out.println("m1"); …
Vishrant
  • 15,456
  • 11
  • 71
  • 120