//轮胎
public class Tire {
private int size;
private String color;
public Tire(int size) {
System.out.println("tire size:"+size);
}
}
//底盘
public class Bottom {
private Tire tire;
public Bottom(int size) {
tire = new Tire(size);
System.out.println("tire init...");
}
}
//框架
public class Framework {
private Bottom bottom;
public Framework(int size) {
bottom = new Bottom(size);
System.out.println("bottom init....");
}
}
//汽车
public class Car {
private Framework framework;
public Car(int size) {
framework = new Framework(size);
System.out.println("framework init...");
}
public void run() {
System.out.println("car run...");
}
}
//启动类
public class Main {
public static void main(String[] args)
{
Car car = new Car(10);
car.run();
}
}
//bottom
public class Bottom {
private Tire tire;
public Bottom(Tire tire) {
this.tire = tire;
System.out.println("tire init...");
}
}
//Car
public class Car {
private Framework framework;
public Car(Framework framework) {
this.framework = framework;
System.out.println("framework init...");
}
public void run() {
System.out.println("car run...");
}
}
//Framework
public class Framework {
private Bottom bottom;
public Framework(Bottom bottom) {
this.bottom = bottom;
System.out.println("bottom init....");
}
}
//Tire
public class Tire {
private int size;
private String color;
public Tire(int size, String color) {
System.out.println("tire size:"+size+",color:"+color);
}
}
//Main
public class Main {
public static void main(String[] args) {
Tire tire = new Tire(17, "red");
Bottom bottom = new Bottom(tire);
Framework framework = new Framework(bottom);
Car car = new Car(framework);
car.run();
}
}
@Component
public class UserComponent {
public void doComponent()
{
System.out.println("UserComponent");
}
}
@Configuration
public class UserConfig {
public void doConfig()
{
System.out.println("UserConfig doConfig");
}
}
@Repository
public class UserRepo {
public void doRepo()
{
System.out.println("UserRepo");
}
}
@Service
public class UserService {
public void doService() {
System.out.println("UserService doService");
}
}
@Controller
public class helloTest {
public void hello()
{
System.out.println("hello");
}
}
//启动类
@SpringBootApplication
public class SpringIocApplication {
public static void main(String[] args) {
ConfigurableApplicationContext context = SpringApplication.run(SpringIocApplication.class, args);
helloTest bean = context.getBean(helloTest.class);
bean.hello();
}
}