这是什么问题啊,我网上搜了好多都没用
因为你用的是
ApplicationContext context = new ClassPathXmlApplicationContext("application.xml"); 来获取spring的容器,那么你就需要在相应的xml中配置你的bean,把你配置的bean加载到spring容器中,
当我们使用ClassPathXmlApplicationContext的时候 ,容器会从给定xml文件中加载bean定义。
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<!-- 定义一个Bean -->
<bean id="testController" class="com.mall.algorithm.TestController">
<!-- bean 配置 -->
</bean>
</beans>