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

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -