|
@@ -1,13 +1,13 @@
|
|
package com.huashe.park.application.mybatis;
|
|
package com.huashe.park.application.mybatis;
|
|
|
|
|
|
|
|
+import java.util.List;
|
|
|
|
+
|
|
import org.apache.ibatis.session.SqlSessionFactory;
|
|
import org.apache.ibatis.session.SqlSessionFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.context.ApplicationListener;
|
|
import org.springframework.context.ApplicationListener;
|
|
import org.springframework.context.event.ContextRefreshedEvent;
|
|
import org.springframework.context.event.ContextRefreshedEvent;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
-import java.util.List;
|
|
|
|
-
|
|
|
|
@Component
|
|
@Component
|
|
public class RegisterCustomerInterceptor implements ApplicationListener<ContextRefreshedEvent> {
|
|
public class RegisterCustomerInterceptor implements ApplicationListener<ContextRefreshedEvent> {
|
|
/**
|
|
/**
|
|
@@ -22,8 +22,9 @@ public class RegisterCustomerInterceptor implements ApplicationListener<ContextR
|
|
@Override
|
|
@Override
|
|
public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
|
|
public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
|
|
for (SqlSessionFactory factory : sqlSessionFactories) {
|
|
for (SqlSessionFactory factory : sqlSessionFactories) {
|
|
- //由于mybatis拦截器使用责任链模式,有可能会导致自定义拦截器失效,因此下面方法可以将自定义拦截器重新注入到sql中
|
|
|
|
|
|
+ // 由于mybatis拦截器使用责任链模式,有可能会导致自定义拦截器失效,因此下面方法可以将自定义拦截器重新注入到sql中
|
|
factory.getConfiguration().addInterceptor(mybatisInterceptor);
|
|
factory.getConfiguration().addInterceptor(mybatisInterceptor);
|
|
|
|
+ factory.getConfiguration().setObjectWrapperFactory(new MapWrapperFactory());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|