一、系统所依赖的Jar包。
antlr-2.7.7.jar
aspectjrt.jar
aspectjweaver.jar
c3p0-0.9.2.1.jar
classmate-1.3.0.jar
com.springsource.org.aopalliance-1.0.0.jar
com.springsource.org.apache.commons.dbcp-1.2.2.osgi.jar
com.springsource.org.apache.commons.pool-1.5.3.jar
commons-beanutils-1.8.3.jar
commons-collections-3.2.1.jar
commons-lang-2.5.jar
commons-logging-1.1.1.jar
commons-logging.jar
dom4j-1.6.1.jar
ezmorph-1.0.6.jar
geronimo-jta_1.1_spec-1.1.1.jar
hibernate-c3p0-4.3.11.Final.jar
hibernate-commons-annotations-4.0.5.Final.jar
hibernate-core-4.3.11.Final.jar
hibernate-jpa-2.1-api-1.0.0.Final.jar
hibernate-validator-5.0.3.Final.jar
jackson-annotations-2.5.0.jar
jackson-core-2.5.0.jar
jackson-databind-2.5.0.jar
jandex-1.1.0.Final.jar
javassist-3.18.1-GA.jar
jboss-logging-3.1.3.GA.jar
jboss-logging-annotations-1.2.0.Beta1.jar
jboss-transaction-api_1.2_spec-1.0.0.Final.jar
json-lib-2.4-jdk15.jar
log4j-1.2.17.jar
mchange-commons-java-0.2.3.4.jar
mysql-connector-java-5.1.38-bin.jar
slf4j-api-1.6.1.jar
spring-aop-4.0.0.RELEASE.jar
spring-aspects-4.0.0.RELEASE.jar
spring-beans-4.0.0.RELEASE.jar
spring-context-4.0.0.RELEASE.jar
spring-context-support-4.0.0.RELEASE.jar
spring-core-4.0.0.RELEASE.jar
spring-expression-4.0.0.RELEASE.jar
spring-framework-bom-4.0.0.RELEASE.jar
spring-instrument-4.0.0.RELEASE.jar
spring-instrument-tomcat-4.0.0.RELEASE.jar
spring-jdbc-4.0.0.RELEASE.jar
spring-jms-4.0.0.RELEASE.jar
spring-messaging-4.0.0.RELEASE.jar
spring-orm-4.0.0.RELEASE.jar
spring-oxm-4.0.0.RELEASE.jar
spring-test-4.0.0.RELEASE.jar
spring-tx-4.0.0.RELEASE.jar
spring-web-4.0.0.RELEASE.jar
spring-webmvc-4.0.0.RELEASE-sources.jar
spring-webmvc-4.0.0.RELEASE.jar
spring-webmvc-portlet-4.0.0.RELEASE.jar
spring-websocket-4.0.0.RELEASE.jar
validation-api-1.1.0.Final.jar
二、web.xml配置
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> <display-name>StoreManagerSystem-MVC</display-name> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> <welcome-file>default.html</welcome-file> <welcome-file>default.htm</welcome-file> <welcome-file>default.jsp</welcome-file> </welcome-file-list> <!-- 配置log4j --> <context-param> <param-name>log4jConfigLocation</param-name> <param-value>classpath:log4j.properties</param-value> </context-param> <context-param> <param-name>log4jRefreshInterval</param-name> <param-value>3000</param-value> </context-param> <!-- 编码过滤器 --> <!-- 统一采用UTF-8编码 --> <filter> <filter-name>encoding</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> </filter> <filter-mapping> <filter-name>encoding</filter-name> <url-pattern>/</url-pattern> </filter-mapping> <!-- Spring配置文件 --> <!-- Spring -xml --> <servlet> <servlet-name>spring</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/spring-servlet.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>spring</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> <!-- 指定log4j的listener --> <listener> <listener-class> org.springframework.web.util.Log4jConfigListener </listener-class> </listener> <!-- <listener> --> <!-- <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> --> <!-- </listener> --> </web-app>
说明几点:
1、日志采用log4j工具输出,包括输出到Console和本地文件,log4j.properties文件位于classpath路径下面,所以在Web.xml中需要加载该文件,包括配置文件的路径和加载该文件的listener
log4j.properties内容如下
###Root Logger DEBUG < INFO < WARN < ERROR < FATAL log4j.rootLogger=INFO,console,dailyFile,logFile log4j.additivity.org.apache=true ### console log4j.appender.console=org.apache.log4j.ConsoleAppender log4j.appender.console.Threshold=INFO log4j.appender.console.ImmediateFlush=true log4j.appender.console.Target=System.out log4j.appender.console.layout=org.apache.log4j.PatternLayout log4j.appender.console.layout.ConversionPattern=[%-5p] %d(%r) --> [%t] %l: %m %x %n ### logFile log4j.appender.logFile=org.apache.log4j.FileAppender log4j.appender.logFile.Threshold=INFO log4j.appender.logFile.ImmediateFlush=true log4j.appender.logFile.Append=true log4j.appender.logFile.File=E:/ManagerSystem/logs/log/log.log4j log4j.appender.logFile.layout=org.apache.log4j.PatternLayout log4j.appender.logFile.layout.ConversionPattern=[%-5p] %d(%r) --> [%t] %l: %m %x %n ### rollingFile log4j.appender.rollingFile=org.apache.log4j.RollingFileAppender log4j.appender.rollingFile.Threshold=INFO log4j.appender.rollingFile.ImmediateFlush=true log4j.appender.rollingFile.Append=true log4j.appender.rollingFile.File=E:/ManagerSystem/logs/rolling/log.log4j log4j.appender.rollingFile.MaxFileSize=200KB log4j.appender.rollingFile.MaxBackupIndex=50 log4j.appender.rollingFile.layout=org.apache.log4j.PatternLayout log4j.appender.rollingFile.layout.ConversionPattern=[%-5p] %d(%r) --> [%t] %l: %m %x %n ### dailyFile ## '.'yyyy-MM # every month ## '.'yyyy-ww # every week ## '.'yyyy-MM-dd # every day ## '.'yyyy-MM-dd-a # twice a day ## '.'yyyy-MM-dd-HH # every hour ## '.'yyyy-MM-dd-HH-mm # every minute log4j.appender.dailyFile=org.apache.log4j.DailyRollingFileAppender log4j.appender.dailyFile.Threshold=DEBUG log4j.appender.dailyFile.ImmediateFlush=true log4j.appender.dailyFile.Append=true log4j.appender.dailyFile.File=E:/ManagerSystem/logs/daily/log.log4j log4j.appender.dailyFile.DatePattern='.'yyyy-MM-dd log4j.appender.dailyFile.layout=org.apache.log4j.PatternLayout log4j.appender.dailyFile.layout.ConversionPattern=[%-5p] %d(%r) --> [%t] %l: %m %x %n ### spring default level log4j.logger.org.springframework=INFO ### hibernate default level log4j.logger.org.hibernate=INFO ### apache log4j.logger.org.apache=ERROR log4j.logger.net.sf.ehcache=ERROR ### socket #log4j.appender.socket=org.apache.log4j.RollingFileAppender #log4j.appender.socket.RemoteHost=localhost #log4j.appender.socket.Port=5001 #log4j.appender.socket.LocationInfo=true ### Set up for Log Factor 5 #log4j.appender.socket.layout=org.apache.log4j.PatternLayout #log4j.appender.socket.layout.ConversionPattern=[%-5p] %d(%r) --> [%t] %l: %m %x %n ### Log Factor 5 Appender #log4j.appender.LF5_APPENDER=org.apache.log4j.lf5.LF5Appender #log4j.appender.LF5_APPENDER.MaxNumberOfRecords=2000 ### Email #log4j.appender.mail=org.apache.log4j.net.SMTPAppender #log4j.appender.mail.Threshold=FATAL #log4j.appender.mail.BufferSize=10 #log4j.appender.mail.From = [email protected] #log4j.appender.mail.SMTPHost=mail.com #log4j.appender.mail.Subject=Log4J Message #log4j.appender.mail.To= [email protected] #log4j.appender.mail.layout=org.apache.log4j.PatternLayout #log4j.appender.mail.layout.ConversionPattern=[%-5p] %d(%r) --> [%t] %l: %m %x %n ### Database #log4j.appender.database=org.apache.log4j.jdbc.JDBCAppender #log4j.appender.database.URL=jdbc:mysql://localhost:3306/test #log4j.appender.database.driver=com.mysql.jdbc.Driver #log4j.appender.database.user=root #log4j.appender.database.password= #log4j.appender.database.sql=INSERT INTO LOG4J (Message) VALUES('=[%-5p] %d(%r) --> [%t] %l: %m %x %n') #log4j.appender.database.layout=org.apache.log4j.PatternLayout #log4j.appender.database.layout.ConversionPattern=[%-5p] %d(%r) --> [%t] %l: %m %x %n ### Appender #log4j.appender.im = net.cybercorlin.util.logger.appender.IMAppender #log4j.appender.im.host = mail.cybercorlin.net #log4j.appender.im.username = username #log4j.appender.im.password = password #log4j.appender.im.recipient = [email protected] #log4j.appender.im.layout=org.apache.log4j.PatternLayout #log4j.appender.im.layout.ConversionPattern=[%-5p] %d(%r) --> [%t] %l: %m %x %n
2、项目统一采用UTF-8编码
3、Spring核心配置
<span style="white-space:pre"> </span><servlet> <servlet-name>spring</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/spring-servlet.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>spring</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping>
该配置的作用是,加载位于<span style="font-family: Arial, Helvetica, sans-serif;">/WEB-INF目录下的</span><span style="font-family: Arial, Helvetica, sans-serif;">spring-servlet.xml文件,并将所有请求交给</span><span style="font-family: Arial, Helvetica, sans-serif;">DispatcherServlet处理。至于其详细的作用,请自行了解。</span>
三、spring-servlet.xml配置
该配置问主要配置,包括项目所要用到的数据源(database)、操作数据库的session,管理session的事物(transaction),Bean、拦截器(Interceptor)、AOP以及视图解析器。
详细配置如下
<?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:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> <!-- 配置databaseSource --> <!-- ====================================== --> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver"></property> <property name="url" value="jdbc:mysql://localhost:3306/storemanager?characterEncoding=utf-8"></property> <property name="username" value="root"></property> <property name="password" value="123456"></property> <!-- 连接池初始化连接个数 --> <property name="initialSize" value="3" /> <!-- 连接池的最大值 --> <property name="maxActive" value="10" /> <!-- 最大空闲值.当经过一个高峰时间后,连接池可以慢慢将已经用不到的连接慢慢释放一部分,一直减少到maxIdle为止 --> <property name="maxIdle" value="5" /> <!-- 最小空闲值.当空闲的连接数少于阀值时,连接池就会预申请去一些连接,以免洪峰来时来不及申请 --> <property name="minIdle" value="2" /> <!-- 获取连接最大等待时间 --> <!-- <property name="maxWait" value="60000" /> --> <!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 --> <property name="timeBetweenEvictionRunsMillis" value="60000" /> <!-- 配置一个连接在池中最小生存的时间,单位是毫秒 --> <property name="minEvictableIdleTimeMillis" value="25200000" /> <!-- 打开removeAbandoned功能 --> <property name="removeAbandoned" value="true" /> <!-- 1800秒,也就是30分钟 --> <property name="removeAbandonedTimeout" value="1800" /> <!-- 关闭abanded连接时输出错误日志 --> <property name="logAbandoned" value="true" /> <!-- 监控数据库 --> <!-- <property name="filters" value="mergeStat" /> --> <!-- <property name="filters" value="stat" /> --> </bean> <!-- 配置sessionFactory,用于获取session --> <!-- ====================================== --> <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"> <property name="dataSource"> <ref bean="dataSource" /> </property> <property name="mappingResources"> <list> <value>com/kl/napchen/store/bean/User.hbm.xml</value> <value>com/kl/napchen/store/bean/ProductIn.hbm.xml</value> <value>com/kl/napchen/store/bean/ProductOut.hbm.xml</value> <value>com/kl/napchen/store/bean/ProductType.hbm.xml</value> </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect"> org.hibernate.dialect.MySQL5Dialect </prop> <prop key="hibernate.hbm2ddl.auto">update</prop> <prop key="hibernate.format_sql">true</prop> <prop key="hibernate.show_sql">true</prop> <prop key="current_session_context_class">thread</prop> </props> </property> <!-- 自动扫描注解方式配置的hibernate类文件 --> <!-- <property name="packagesToScan"> --> <!-- <list> --> <!-- <value>light.mvc.model</value> --> <!-- </list> --> <!-- </property> --> </bean> <!-- 配置事务管理器 --> <!-- ====================================== --> <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> <!-- <property name="rollbackOnCommitFailure" value="true" /> --> </bean> <!-- 注解方式配置事物 --> <!-- ====================================== --> <!-- <tx:annotation-driven transaction-manager="transactionManager" /> --> <!-- AOP方式配置事物 --> <!-- ====================================== --> <tx:advice id="transactionAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="get*" propagation="REQUIRED" read-only="true" /> <tx:method name="add*" propagation="REQUIRED" /> <tx:method name="delete" propagation="REQUIRED" /> <tx:method name="*" propagation="REQUIRED" /> </tx:attributes> </tx:advice> <aop:config> <aop:pointcut id="transactionPointcut" expression="execution(* com.kl.napchen.store.impl..*.*(..))" /> <aop:advisor pointcut-ref="transactionPointcut" advice-ref="transactionAdvice" /> </aop:config> <!-- 配置Bean --> <!-- ====================================== --> <bean id="user" class="com.kl.napchen.store.bean.User"></bean> <bean id="productIn" class="com.kl.napchen.store.bean.ProductIn"></bean> <bean id="productOut" class="com.kl.napchen.store.bean.ProductOut"></bean> <bean id="productType" class="com.kl.napchen.store.bean.ProductType"></bean> <bean id="sessionInfo" class="com.kl.napchen.store.global.SessionInfo"></bean> <bean id="pageGrid" class="com.kl.napchen.store.page.PageGrid"></bean> <!-- 配置操作数据的Dao --> <!-- ====================================== --> <bean id="userDao" class="com.kl.napchen.store.dao.UserDao"></bean> <bean id="productInDao" class="com.kl.napchen.store.dao.ProductInDao"></bean> <bean id="productOutDao" class="com.kl.napchen.store.dao.ProductOutDao"></bean> <bean id="productTypeDao" class="com.kl.napchen.store.dao.ProductTypeDao"></bean> <!-- 配置业务处理的service --> <!-- ====================================== --> <bean id="userImpl" class="com.kl.napchen.store.impl.UserImpl"></bean> <bean id="productInImpl" class="com.kl.napchen.store.impl.ProductInImpl"></bean> <bean id="productOutImpl" class="com.kl.napchen.store.impl.ProductOutImpl"></bean> <bean id="productTypeImpl" class="com.kl.napchen.store.impl.ProductTypeImpl"></bean> <!-- 配置控制流程的controller --> <!-- ====================================== --> <!-- <bean id="userController" class="com.kl.napchen.store.controller.UserController"></bean> --> <!-- <bean id="productInController" class="com.kl.napchen.store.controller.ProductInController"></bean> --> <!-- <bean id="productOutController" class="com.kl.napchen.store.controller.ProductOutController"></bean> --> <!-- <bean id="productTypeController" class="com.kl.napchen.store.controller.ProductTypeController"></bean> --> <!-- 启用aspectj注解自动代理 --> <!-- ====================================== --> <aop:aspectj-autoproxy /> <!-- 配置写Log的代理bean --> <!-- ====================================== --> <bean id="productLogAdvice" class="com.kl.napchen.store.annotation.log.ProductLogAdvice"></bean> <bean id="productTypeLogAdvice" class="com.kl.napchen.store.annotation.log.ProductTypeLogAdvice"></bean> <bean id="userLogAdvice" class="com.kl.napchen.store.annotation.log.UserLogAdvice"></bean> <!-- 配置权限管理的代理bean --> <!-- ====================================== --> <bean id="productAuthorityAdvice" class="com.kl.napchen.store.annotation.authority.ProductAuthorityAdvice"></bean> <bean id="productTypeAuthorityAdvice" class="com.kl.napchen.store.annotation.authority.ProductTypeAuthorityAdvice"></bean> <bean id="userAuthorityAdvice" class="com.kl.napchen.store.annotation.authority.UserAuthorityAdvice"></bean> <!-- 配置获取spring容器中Bean的工具Bean --> <!-- 由于持有ApplicationContext, --> <!-- 可以使用SpringContextHolder.getBean('xx')的静态方法得到spring bean对象 --> <!-- ====================================== --> <!-- <bean class="com.kl.napchen.storeManagerSystem.contextHolder.SpringContextHolder" lazy-init="false" /> --> <!-- 对静态资源文件的访问 方案一 (二选一) --> <!-- 使用"*.do"配置DispatcherServlet时不存在静态资源访问问题 ,拦截器将不会拦截静态资源的URL --> <!-- 使用"/"配置DispatcherServlet时存在静态资源访问问题,采用以下两种方案解决 --> <!-- ====================================== --> <mvc:default-servlet-handler /> <!-- 对静态资源文件的访问 方案二 (二选一) --> <!-- ====================================== --> <!-- 静态资源映射 --> <!-- <mvc:resources mapping="/js/**" location="/WEB-INF/js/" /> --> <!-- <mvc:resources mapping="/css/**" location="/WEB-INF/css/" /> --> <!-- <mvc:resources mapping="/fonts/**" location="/WEB-INF/fonts/" /> --> <!-- <mvc:resources mapping="/plugins/**" location="/WEB-INF/plugins/" /> --> <!-- <mvc:resources mapping="images/**" location="/WEB-INF/images/" /> --> <!-- 默认的注解映射的支持 --> <!-- 采用这下面种方式将自动装配DefaultAnnotationHandlerMapping和AnnotationMethodHandlerAdapter --> <!-- 采用这下面种方式将无法在 DefaultAnnotationHandlerMapping配置拦截器 --> <!-- ====================================== --> <mvc:annotation-driven /> <!-- 隐式地向 Spring容器注册这4个BeanPostProcessor --> <!-- AutowiredAnnotationBeanPostProcessor、 --> <!-- RequiredAnnotationBeanPostProcessor、 --> <!-- CommonAnnotationBeanPostProcessor、 --> <!-- PersistenceAnnotationBeanPostProcessor --> <!-- ====================================== --> <!-- <context:annotation-config /> --> <!-- 设置使用注解的类所在的jar包 ,使用这种即可省去上面的声明 --> <!-- ====================================== --> <context:component-scan base-package="com.kl.napchen.store.controller" /> <context:component-scan base-package="com.kl.napchen.store.impl" /> <context:component-scan base-package="com.kl.napchen.store.baseService" /> <!-- 映射“/”的url --> <!-- ====================================== --> <!-- <mvc:view-controller path="/" view-name="forward:/index2" /> --> <!-- configure the InternalResourceViewResolver --> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" id="internalResourceViewResolver"> <!-- <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" /> --> <!-- 前缀 --> <property name="prefix" value="/WEB-INF/jsp/" /> <!-- 后缀 --> <property name="suffix" value=".jsp" /> </bean>
<pre name="code" class="html"><span style="white-space:pre"> </span><!-- 配置 DefaultAnnotationHandlerMapping和AnnotationMethodHandlerAdapter --> <!-- ====================================== --> <!-- <bean --> <!-- class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"> --> <!-- 配置拦截器 --> <!-- <property name="interceptors"> --> <!-- <list> --> <!-- <bean class="com/kl/napchen/storeManagerSystem/interceptor/MyInterceptor"></bean> --> <!-- </list> --> <!-- </property> --> <!-- </bean> --> <!-- <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"> </bean> -->
<!-- 自定义拦截器 --><!-- ====================================== --><mvc:interceptors><!-- 使用bean定义一个Interceptor,直接定义在mvc:interceptors根下面的Interceptor将拦截所有的请求 --><bean class="com.kl.napchen.store.interceptor.LogInterceptor"><!--
配置不需要拦截的Url --><!-- 静态资源不拦截 --><property name="excludedUrls"><list><value>.jpg</value><value>.png</value><value>.gif</value><value>.ico</value><value>.css</value><value>.js</value><value>.ttf</value><value>.woff</value><value>.woff2</value></list></property></bean><!--
用于权限管理的拦截器,并不能精确到每一个操作数据库的方法,精确的控制采用advice --><mvc:interceptor><mvc:mapping path="/*" /><bean class="com.kl.napchen.store.interceptor.AuthorityInterceptor"><!-- 配置不需要拦截的Url --><!-- 只在登录和注册时不验证 --><property name="excludedUrls"><list><value>/index</value><value>/register</value><value>/login</value></list></property></bean></mvc:interceptor></mvc:interceptors></beans>
说明
1、
<span style="white-space:pre"> </span><!-- 注解方式配置事物 --> <!-- ====================================== --> <!-- <tx:annotation-driven transaction-manager="transactionManager" /> --> <!-- AOP方式配置事物 --> <!-- ====================================== --> <tx:advice id="transactionAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="get*" propagation="REQUIRED" read-only="true" /> <tx:method name="add*" propagation="REQUIRED" /> <tx:method name="delete" propagation="REQUIRED" /> <tx:method name="*" propagation="REQUIRED" /> </tx:attributes> </tx:advice> <aop:config> <aop:pointcut id="transactionPointcut" expression="execution(* com.kl.napchen.store.impl..*.*(..))" /> <aop:advisor pointcut-ref="transactionPointcut" advice-ref="transactionAdvice" /> </aop:config>
采用注解的方式和采用AOP的方式都可以达到相同的目的。采用注解方式这需要用@transition注解标注service。
拦截器也有两种配置方法,具体见xml文件和注释,在本项目采取的方法中,其中的property属性需要注意,它采用一个list来配置该拦截器不需要拦截的Uri。因为拦截器并没有提供反向排除的配置方式,故先拦截所有,然后在拦截器中剔除部分。详细的剔除代码将在拦截器的Java代码中给出。
以上就是该项目的配置文件。