【Spring】Spring开启注解配置

来源:互联网 发布:网络教研三剑客 编辑:程序博客网 时间:2024/05/29 15:52

Spring有注解用法,但需要在配置文件Spring.xml下开启

Spring.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:p="http://www.springframework.org/schema/p"xmlns:c="http://www.springframework.org/schema/c" xmlns:context="http://www.springframework.org/schema/context"xmlns:aop="http://www.springframework.org/schema/aop"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        http://www.springframework.org/schema/aop        http://www.springframework.org/schema/aop/spring-aop.xsd"><!-- 开启注解配置,有扫包配置可省去 --><context:annotation-config /><!-- 对指定的包进行组件扫描 --><context:component-scan base-package="com.duxd" /><!-- 开启AOP注解 --><aop:aspectj-autoproxy/></beans>

原创粉丝点击