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

Popular posts from this blog

xml - Extract substrings with XSLT -

math - "ELO Rating" and how does "TSR Rating" work? -

How can do a tuple comparison in coffeescript similar to that in python? -