Answer the question
In order to leave comments, you need to log in
How to get bean in spring?
I master the configuration of a spring application through annotations, I try to create a bean like this:
@Configuration
class Service{
@Bean(name="service")
public Service service(){
return new Service();
}
public double getDouble(){
return 01.02;
}
}
ApplicationContext context = new ClassPathXmlApplicationContext("ApplicationContext.xml");
Service service = (Service)context.getBean("service");
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question