坦克大战(一期)-设计模式-工厂模式-理解SpringIOC

DesignPatterns
bingor 2 years ago
parent 7764e0b07e
commit 98546b1759

@ -0,0 +1,19 @@
package com.msb.springIOC;/**
* @Author bingor
* @Date 2022/10/10 11:00
* @Description: com.msb.springAOC
* @Version: 1.0
*/
/**
*@ClassName Driver
*@Description TODO
*@Author bingor
*@Date 2022/10/10 11:00
*@Version 3.0
*/
public class Driver {
public Driver() {
System.out.println("new Driver");
}
}

@ -0,0 +1,23 @@
package com.msb.springIOC;/**
* @Author bingor
* @Date 2022/10/10 11:00
* @Description: com.msb.springAOC
* @Version: 1.0
*/
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
*@ClassName Main
*@Description TODO
*@Author bingor
*@Date 2022/10/10 11:00
*@Version 3.0
*/
public class Main {
public static void main(String[] args) {
ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
// Driver driver = (Driver) context.getBean("driver");
}
}

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="driver" class="com.msb.springIOC.Driver"></bean>
</beans>
Loading…
Cancel
Save