我的应用程序类
import com.example.haha.Haha;
import com.example.hehe.Hehe;
import com.example.logging.Logging;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
@SpringBootApplication
@EnableAspectJAutoProxy
public class DemoApplication {
public static void main(String[] args) throws InterruptedException {
ApplicationContext ctx = SpringApplication.run(DemoApplication.class, args);
for(String name:ctx.getBeanDefinitionNames()){
System.out.println(name);
}
Haha haha = (Haha)ctx.getBean("hh");
haha.haha1();
haha.haha2();
return;
}
}
Run Code Online (Sandbox Code Playgroud)
Haha.java
package com.example.haha;
import org.springframework.stereotype.Component;
/**
* Created by vamsi on 4/21/16.
*/
@Component("hh")
public class Haha {
public Haha(){
}
public void haha1() throws InterruptedException {
System.out.println("In method …Run Code Online (Sandbox Code Playgroud)