How Do I wire this class in Spring.
1) Annotation
2) Xml
note: I can already wire other classes just not sure how to wire a class in this scenario
Class<? super Client >
enter code here
public class ClientData2 extends ContainerClass<Client>
{
public ClientData2(Class<? super Client> type)
throws IllegalArgumentException
{
super(type);
}
}
If you have a bean of type
Class, it’s the same as everything else – with@Autowired/@Inject(and optionally@Qualifier)How to create such a bean? Multiple ways:
factory-method="forName"andconstructor-argpassingjava.lang.ClassFactoryBeanthat producesClassobjectsHowever, it is is a bit strange that you need a
Classobject as bean – you can’t inject any dependencies in it. Perhaps you can simply inject the class name (with@Value("${class.name}")) and then useClass.forName(..)in a@PostConstructmethod.