java - how to autowire @bean classes -
i have following @configuration
class
@configuration public class someclass { @bean public beanclass get() { return new beanclass() } }
now want autowire beanclass in other class
public class someclass2 { @autowired beanclass beanclass }
currently beanclass coming null.
, how need tell spring autowiring.
according spring documentation
by default, bean name of method name
get
bean name, try configuration:
@configurtion public class someclass { @bean public beanclass beanclass() { return new beanclass() } }
bean
@component public class someclass2 { @autowired beanclass beanclass }
Comments
Post a Comment