Spring Bean管理3(xml与注解混合使用)

<?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.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">

    <context:annotation-config/>   <!--使用此标签,可使用属性注入等注解,但无法使用@Component等将类交由Spring管理的注解-->

    <bean id="productService" class="com.demo3.ProductService"/>     <!--将类交由Spring管理-->

    <bean id="productDao" class="com.demo3.ProductDao"/>

    <bean id="categoryDao" class="com.demo3.CategoryDao"/>
</beans>

猜你喜欢

转载自www.cnblogs.com/shouyaya/p/12528183.html