Spring配置文件

<?xml version="1.0" encoding="UTF-8"?>
<!--xmlns="http://www.springframework.org/schema/beans"根据该值修改-->
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:p="http://www.springframework.org/schema/p"
       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/beans/spring-context.xsd
                http://www.springframework.org/schema/aop
                http://www.springframework.org/schema/beans/spring-aop.xsd">

    <!--开启注解的支持-->
    <context:annotation-config/>
    <!--开启注解的扫描 todo:指定扫描的包名-->
    <context:component-scan base-package=""/>
    <!--扫描@Aspect注解, 如果有该注解将该类设置为代理类, 生成的对象即为代理对象-->
    <aop:aspectj-autoproxy></aop:aspectj-autoproxy>

    <!--下面是通过配置文件方式实现AOP操作-->
    <bean id="userDaoImpl" class="dao.UserDaoImpl"/>
    <bean id="userDaoProxy" class="dao.UserDaoProxy"/>

    <!--配置aop配置增强-->
    <aop:config>
        <!--切入点表达式-->
        <aop:pointcut id="p" expression="execution(* dao.UserDaoImpl.add(..))"/>

        <!--配置切面: 指定哪个代理类对哪个方法进行增强-->
        <aop:aspect ref="userDaoProxy">
            <!--增强作用在哪个具体的方法上-->
            <aop:before method="before" pointcut-ref="p"/>
            <aop:after method="after" pointcut-ref="p"/>
            <aop:after-returning method="afterReturning" pointcut-ref="p"/>
            <aop:around method="around" pointcut-ref="p"/>
            <aop:after-throwing method="afterThrowing" pointcut-ref="p"/>
        </aop:aspect>
    </aop:config>

log4j配置文件

resources目录下创建log4j.properties

log4j.rootLogger=info,stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apche.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM--dd HH:mm:ss,SSS}%5p --[%50t] %-80c(line:%5L) : %m%n

   转载规则


《》 熊水斌 采用 知识共享署名 4.0 国际许可协议 进行许可。
 上一篇
AOP面向切面编程底层原理: 动态代理动态代理的核心思想: 借助父类或接口的多态性特点, 在形式上, 通过调用原来存在的父类或接口中的方法, 而实际执行的是子类或实现类的代理类中的增强方法 JDK动态代理(针对接口)public class
2022-11-11
下一篇 
前端基础HTMLinput输入框 type属性: 文本框, 单选框, 复选框, 下拉列表, 提交按钮, 重置按钮 get请求和post请求 get请求会将数据添加到url中, 明文数据不安全 post请求一般用于表单数据提交 当属性名和
2022-11-11
  目录