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
2
votes
1 answer

Error handling in spring integration - How to get all the errors thrown in multiple threads and send them to the error-channel

I have two threads and each of the method in the thread throws an exception. How do I get all the errors that's thrown in each of the thread? In this code, the error channel just catch one of the errors. Basically my goal is to catch all the errors…
2
votes
1 answer

How to get list of beans defined in a java config class?

A spring java configuration class can have more than one bean defined in it. I am aware on how to obtain a single bean which is defined in a java spring configuration class. Some thing like - AnnotationConfigApplicationContext ctx = new …
samshers
  • 1
  • 6
  • 37
  • 84
2
votes
1 answer

How to read a file and assign it to an ArrayList in spring?

Consider the following classes: public class Store { private final ArrayList store; public ArrayList getStore() { return store; } public Store(ArrayList store){ this.store = store; } } I…
Adit A. Pillai
  • 647
  • 1
  • 10
  • 22
2
votes
1 answer

How to inject a custom BeanFactory

For a custom Scope (I cannot post here because of legal reasons) I need a custom BeanFactory that overrides the getBean(Class requiredType) method, like: public class MyBeanFactory implements BeanFactory { @Override public T…
t777
  • 3,099
  • 8
  • 35
  • 53
2
votes
0 answers

How I can define spring generic beans using xml

I have to do some unit test where I have to inject generic bean using @Autowired for exemple I have this bean and I want the some with xml configuration How I can do that should I have to use property to do this @Bean public…
e2rabi
  • 4,728
  • 9
  • 42
  • 69
2
votes
1 answer

How to prevent spring context loading on exception in ServletContextListener?

I boostrap spring context using ContextLoaderListener. Before this in web.xml I have my custom listener which pefrorms some checks. If those checks fail i do not want Spring context to be started. How can i prevent Spring context loading if i had…
Kirill
  • 6,762
  • 4
  • 51
  • 81
2
votes
1 answer

How to make sure Flyway loads before my bean?

I have a Spring Boot application in which a Bean loads configuration-data from the database. Right now I set up this Bean in the Configuration class. But it seems it loads before Flyway. How to make sure Flyway has finished it's job before my beans…
yglodt
  • 13,807
  • 14
  • 91
  • 127
2
votes
4 answers

What's the best way to Invoke a service on spring-boot start up?

I have a spring boot application and i need to invoke a service(a rest end point)on start up.
Diva
  • 151
  • 1
  • 3
  • 9
2
votes
1 answer

How do I override InternalResourceViewResolver in spring boot?

I want to override InternalResourceViewResolver or ViewResolver in Springboot project. Anybody have any idea about it? Any suggestions please? EDIT: I have already tried this solution. @Bean public InternalResourceViewResolver defaultViewResolver()…
jalpa
  • 204
  • 1
  • 3
  • 15
2
votes
1 answer

NoSuchBeanDefinitionException while sending E-Mail

I try to send an E-Mail through an Restful Web-Service with Spring-managed services. However I retrieve the following exception: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'messsageservice' is defined …
Pranathi
  • 41
  • 1
  • 5
2
votes
1 answer

Wiring a bean and a value in a constructor

I'm using Spring. I have this class: @Service public class FooService { @Value("${xml.file.path}") String xmlFilePath; @Autowired ResourceLoader ctx; } I really hate wiring properties and would prefer to use a constructor but…
gaijinco
  • 2,146
  • 4
  • 17
  • 16
2
votes
1 answer

Is the beauty of Spring DI -resolving dependences at run-time instead of compile-time has lost in Java Based Configuration?

Using Spring Dependency Injection we can remove the hard-coded dependencies from our code and dependences can be resolved at run-time instead of compile-time. In few years ago, we were working in a project which was implemented for two countries.…
Bacteria
  • 8,406
  • 10
  • 50
  • 67
2
votes
1 answer

using multiple implementations for a 3rd party library in spring: stuck finding a clean approach

I am implementing a custom authentication provider which has to authenticate and authorize user (through one time token/password). There is a server already in place for this purpose, and we have been provided a client API to use in our application…
Anadi Misra
  • 1,925
  • 4
  • 39
  • 68
2
votes
2 answers

Creating bean using static method from another class

I have a factory class which has various static methods to return the instances of some classes. How can a bean be created in spring using static factory method in different class? something like: public class InstanceFactory { public static…
varun
  • 684
  • 1
  • 11
  • 30
2
votes
3 answers

Spring @PreDestroy method

I found out that @PreDestroy only work with singleton scoped bean. I was thinking what could go wrong if we use it with prototype scoped bean. Anything at all??? I dont think so. I think this is just not implemented in spring as they would have to…
varun
  • 684
  • 1
  • 11
  • 30