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

How can I do parameterized dependency injection with Spring?

I was wondering how to solve the following problem using Spring dependency injection: Given that I have a list of Transactions of different types, I'd need to process them based on their TransactionType. So I’d have a TransactionController with a…
Tarek
  • 3,080
  • 5
  • 38
  • 54
0
votes
1 answer

Spring Application Context Not getting Property from application.properties file

I am creating a console app with spring and gradle. I would like to include information in my application.properties file for my program to access. Above is a picture of what my class structure looks like for this tool. Here is the…
user3108671
  • 83
  • 1
  • 2
  • 10
0
votes
1 answer

Can't get Spring bean

I have a Spring project in which I want to get a specific Spring bean defined in my Spring beans XML File. My Spring bean XML file is located at /WEB-INF/spring/root-context.xml. Here is my code in the Service class: ApplicationContext context = new…
0
votes
1 answer

Entity Manager Object in SimpleTask executor thread

I want to do some database operation asynchronously. I am using spring 3.0. So i used @Async annotation. public class TaskExecutorExample { public static void main(String a[]) { ApplicationContext…
Gowtham R
  • 786
  • 2
  • 9
  • 17
0
votes
4 answers

After upgrade, tests pass in Eclipse, fail in Maven, Spring throws BeanCreationException / NoClassDefFoundError $proxy10

After doing a Spring / Hibernate upgrade to the latest versions, I hit problems running my tests under maven. org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'protoEntityManager' defined in class path…
Adam
  • 5,215
  • 5
  • 51
  • 90
0
votes
1 answer

Spring IOC w/ generics - inject dependencies based on dependent's type parameter

I want to instantiate a generic bean with a type parameter, and have the correct dependents wired based on this type parameter. Suppose I have: @Named public Parent { @Inject Parent(Child c) { ... } } public interface…
tekumara
  • 8,357
  • 10
  • 57
  • 69
0
votes
0 answers

Spring Returning eagerly cached - a consequence of a circular reference

I am working on a problem in one of the application I am working on. I am getting the below error. | DEBUG | org.springframework.beans.factory.support.DefaultListableBeanFactory [237] | Returning eagerly cached instance of singleton bean…
Kumar
  • 1,106
  • 4
  • 15
  • 33
0
votes
1 answer

Do I have to drop @Component when wanting to set bean parameters via JavaConfig? Is there another way?

I've got a Spring bean that is annotated with @Component. But I want to set/specify bean parameters. From what I can tell, my only option if I want to stick with annotations is to use an @Configuration class to specify the parameters when the bean…
Eric B.
  • 23,425
  • 50
  • 169
  • 316
0
votes
1 answer

Is creating Spring prototype beans faster than creating singletons?

Is a prototype bean created faster by the spring container than a singleton bean? How much if yes? Maybe some background for the question. Assume that we have the context definition which contains a lot of bean definitions. And the application is a…
Łukasz Rzeszotarski
  • 5,791
  • 6
  • 37
  • 68
0
votes
2 answers

Spring generic Hibernate DAO

I am writing a Generic Hibernate DAO class that all Hibernate DAO classes will inherit from. I am trying to use spring to inject the dependencies for the classes but I am getting an exception. @Repository public class HibernateDaoImpl
user2054833
  • 2,115
  • 7
  • 24
  • 39
0
votes
1 answer

Inject based on the package of the class

I have 2 modules containing classes: blog.model.ArticleDAO blog.model.CategoryDAO users.model.UserDAO users.model.UserGroupDAO All these DAOs have a dependency on the same service, but I need to inject a different instance based on the package. I…
Matthieu Napoli
  • 48,448
  • 45
  • 173
  • 261
0
votes
3 answers

Which classes area loaded as bean in Spring ??

I am new to Spring framework.While reading dependency injection i found out two ways to inject beans anotationbased and xml based. In xmlBased it is quite simple that you define one bean inside your application context xml file. eg.
JOHND
  • 2,597
  • 6
  • 27
  • 35
0
votes
2 answers

Injecting MessageSource into an Enum

I am trying to use an ENUM for a form:select as such: With an Enum that looks something like: public enum MyEnum { ONE("rb.one"), TWO("rb.two"); …
CodeChimp
  • 8,016
  • 5
  • 41
  • 79
0
votes
2 answers

Constructor Depending injection with dynamic primitive values that are determined at run time

I have constructors that need dynamic values at rum time and was wondering if it still can use dependency injection.Please let me know how can i do dependency injection using spring in this case. public class User { private String username; …
0
votes
2 answers

Spring InitializingBean interface

In XML file in spring we have two bean with different id but same class. They have the same properties offcourse. Now I have InitializingBean interface and in afterPropertySet() I am just printing the value of properties. Its printing the values…
user728907
  • 33
  • 6
1 2 3
12
13