今天干了个傻傻的事情-查看文章

今天干了个傻傻的事情

发表于:2017-06-21 19:44:58 分类:JAVA 阅读:1053次

自定义切面类型是class,我竟然生成了一个aspect文件(这难道是高版本的?),然后导致编译不通过。但是因为是注解注入的bean,竟然不报错。找了半天,切面一直进入不了。

最后没办法,配置了bean注入。启动报没有发现类的错误。当时不知道,以为是配置的问题,但是配置里又是可以点到的,浪费半天的时间。最后想到是不是没有生成class文件,到部署的目录一看,果然没有。。。。

接着把类型改成了class,启动一样。

然后的然后,把原来的文件删除了,内容复制过去,再启动就好了。。。。。。

<?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"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:tx="http://www.springframework.org/schema/tx"
       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
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">

    <!--打开切面编程支持-->
    <aop:aspectj-autoproxy proxy-target-class="true"/>
    <!--打开注解-->
    <context:annotation-config/>
    <context:component-scan base-package="top.ersredma.blog" />
    <context:component-scan base-package="top.ersredma.blog.aop" />
    <context:property-placeholder location="classpath:./top/ersredma/blog/resource/jdbc.properties"/>

    <bean class="org.mybatis.spring.SqlSessionFactoryBean" id="sqlSessionFactory">
        <property name="dataSource" ref="dataSource"/>
        <property name="configLocation" value="classpath:./top/ersredma/blog/resource/mybatis-config.xml"></property>
        <property name="mapperLocations" value="classpath:./top/ersredma/blog/dao/**.xml"/>
    </bean>

    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="basePackage" value="top.ersredma.blog.dao"/>
        <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
    </bean>

    <!--事务管理 注解方式-->
    <tx:annotation-driven transaction-manager="transactionManager"/>

    <bean class="org.springframework.jdbc.datasource.DataSourceTransactionManager" id="transactionManager">
        <property name="dataSource" ref="dataSource"/>
    </bean>

    <bean id="XssAspect" class="top.ersredma.blog.aop.AntiXSSAspect">
    </bean>
    <!--<aop:config>-->
        <!--<aop:aspect ref="XssAspect"/>-->
        <!---->
    <!--</aop:config>-->

    <bean class="com.alibaba.druid.pool.DruidDataSource" id="dataSource" destroy-method="close" init-method="init">
        <property name="url" value="${jdbc_url}"/>
        <property name="username" value="${jdbc_username}"/>
        <property name="password" value="${jdbc_password}"/>
        <!--初始化连接大小-->
        <property name="initialSize" value="5"/>
        <!--连接池最大使用连接数据-->
        <property name="maxActive" value="20"/>
        <!--连接池最小空闲-->
        <property name="minIdle" value="0"/>
        <!--初始化最大等待时间-->
        <property name="maxWait" value="6000"/>
        
        <property name="validationQuery" value="${validationQuery}"/>
        <property name="testOnBorrow" value="false"/>
        <property name="testOnReturn" value="false"/>
        <property name="testWhileIdle" value="true"/>
        <!--配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位为毫秒-->
        <property name="timeBetweenEvictionRunsMillis" value="60000"/>
        <!--配置一个连接在池内最小生存时间,单位为毫秒-->
        <property name="minEvictableIdleTimeMillis" value="25200000"/>
        <!--打开removeAbandoned功能-->
        <property name="removeAbandoned" value="true"/>
        <!--30分钟-->
        <property name="removeAbandonedTimeoutMillis" value="1800"/>
        <!--关闭abanded连接时输出错误日志-->
        <property name="logAbandoned" value="true"/>
        <!--监控数据库-->
        <property name="filters" value="mergeStat"/>
    </bean>
</beans>


关键词:自定义,切面编程,aop


验证码:

  1. author
    陆冠英(伪装者) 2017-07-02 12:58:44
    回复:鲁有脚

    test

    66666
  2. author
    鲁有脚(伪装者) 2017-06-27 14:22:04
    test
  3. author
    渔人(伪装者) 2017-06-24 16:41:47
    不错啊
  4. author
    忽都虎(伪装者) 2017-06-24 00:12:08
    2333
  5. author
    马青雄(伪装者) 2017-06-23 14:25:49
    厉害了
  6. author
    曲三(伪装者) 2017-06-21 20:04:54
    6666
  7. author
    郭大叔 2017-06-21 19:45:32
    欢迎js注入。。