spring boot 複数DBに接続時interceptor無効になるについて
5335 ワード
step1
@Import({DataSourceConfiguration.class,PageInterceptor.class})
step2
@Autowired
private PageInterceptor pageInterceptor;
step3
sqlSessionFactoryBean.setPlugins(newInterceptor[]{pageInterceptor});
step3は「sqlSessionFactoryBean.getObject()」前に書く
原因
sqlSessionFactoryBean.getObject()
public SqlSessionFactory getObject() throws Exception {
if (this.sqlSessionFactory == null) {
afterPropertiesSet();
}
return this.sqlSessionFactory;
}
public void afterPropertiesSet() throws Exception {
notNull(dataSource, "Property 'dataSource' is required");
notNull(sqlSessionFactoryBuilder, "Property 'sqlSessionFactoryBuilder' is required");
state((configuration == null && configLocation == null) || !(configuration != null && configLocation != null),
"Property 'configuration' and 'configLocation' can not specified with together");
this.sqlSessionFactory = buildSqlSessionFactory();
}
if (!isEmpty(this.plugins)) {
for (Interceptor plugin : this.plugins) {
configuration.addInterceptor(plugin);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Registered plugin: '" + plugin + "'");
}
}
}
Author And Source
この問題について(spring boot 複数DBに接続時interceptor無効になるについて), 我々は、より多くの情報をここで見つけました https://qiita.com/ryuumikoto/items/5ae70e6d201ac52dbcc5著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .