• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

spring injection without bean reference

 
praveen Shangunathan
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to inject a class type using a setter. I am able to do it by defining what i want to inject as a bean.
How can I do this without having to define what I am injecting as a bean.

When I tried <property name="name" value="com.foo.bar.className"> I get a type mismatch error that string cannot be cast to className.

Please advice.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well if you really don't want to create a <bean> for that other object, you could implement FactoryBean, and in the getObject() create an instance of the object you want to inject and call the setter.

Or you can define that other object as a bean.

Mark
 
praveen Shangunathan
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Mark.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic