cn.vonce.sql.spring.config.ConditionalOnUseMybatis Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of vonce-sqlbean-spring Show documentation
Show all versions of vonce-sqlbean-spring Show documentation
This is a tool that uses java object-oriented idea to write and generate SQL statements. On this basis,
it also implements lightweight plug-in support similar to JPA for mybatis and spring JDBC. A large number of
common SQL execution methods are built in plug-ins to improve development efficiency, reduce a large number of
SQL statement writing, and make developers focus on business code writing.
The newest version!
package cn.vonce.sql.spring.config;
import cn.vonce.sql.spring.mapper.MybatisSqlBeanMapperInterceptor;
import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;
/**
* 根据使用Mybatis来配置插件
*
* @author Jovi
* @version 1.0
* @email [email protected]
* @date 2019年6月25日下午12:7:50
*/
public class ConditionalOnUseMybatis implements Condition {
@Override
public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata annotatedTypeMetadata) {
String[] beanName = conditionContext.getBeanFactory().getBeanNamesForType(MybatisSqlBeanMapperInterceptor.class);
if (beanName == null || beanName.length == 0) {
try {
Class.forName("org.apache.ibatis.plugin.Interceptor");
return true;
} catch (ClassNotFoundException e) {
return false;
}
}
return true;
}
}