控制台报错:java.lang.NullPointerException也就是说:为Null的字符串调用length()函数会报空指针异常所以:我们要先判断字符串是否为空Cause: org.apache.ibatis.ognl.OgnlException: source is null for getProperty(null, "length")getProperty(null, "l
最近有在学习使用mybatis plus,了解到使用mp代码生成器可以方便快捷的生成代码,为了适用于自己开发需要,自定义了一个mp的代码生成器,增加了几个小功能: 1.增加了Vo类的生成,其实思路很简单,利用生成的entity实体类,复制一份,替换掉其中的几个关键字就可以了。 2.可以根据表名,根据参数判断是否去掉前缀,然后根据剩...
今天介绍一个 MyBatis - Plus 官方发布的神器:mybatis-mate 为 mp 企业级模块,支持分库分表,数据审计、数据敏感词过滤(AC算法),字段加密,字典回写(数据绑定),数据权限,表结构自动生成 SQL 维护等,旨在更敏捷优雅处理数据。 ◆1. 主要功能 字典绑定 字段加密 数据脱敏 表结构动态维护 数据审计记录 数据范围(数...
getProperty("user.dir"); gc.setOutputDir(projectPath + "/src/main/java"); gc.setAuthor("liuwenxu"); gc.setOpen(false); gc.setSwagger2(true); // 实体属性 Swagger2 注解 mpg.setGlobalConfig(gc); // 数据源配置 DataSourceConfig dsc = new DataSourceConfig(); dsc.setUrl("jdbc:mysql:...
org.springframework.core.io.ResourceLoader; import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; import javax.sql.DataSource; import java.util.List;/*** @author xw* @description 重写mybatis-plus 自动配置类* @date 2022/1/7 14:06*/public class AbstractMyb...
mybatis-plus:configuration:log-impl:org.apache.ibatis.logging.stdout.StdOutImpl //标准输出 2、日志配置完成后,在控制台就会生成相应的日志 CreatinganewSqlSession SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@75023c53] wasnotregisteredforsynchronization because synchronizationisnotactive ...
"); } public static void main(String[] args) { // 代码生成器 AutoGenerator mpg = new AutoGenerator(); // 全局配置 GlobalConfig gc = new GlobalConfig(); String projectPath = System.getProperty("user.dir"); // System.out.println("projectPath = " + projectPath); gc.setOutputDir(...
在 sqlSessionFactory()方法中,除了注入 MyBatis本身的组件,还会注入MyBatis-plus 的 主键生成器、SQL 注入器等组件,最后通过 MybatisSqlSessionFactoryBean#getObject() 方法获取到 sqlSessionFactory 对象 @Bean @ConditionalOnMissingBean public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception...
引入依赖说明:mybatis-plus可以节省我们大量的代码,尽量不要同时使用mybatis-plus和mybatis会出现版本问题 配置数据库连接 #mysql 5 driver:com.mysql.jdbc.Driver#mysql 8 driver:com.mysql.cj.jdbc.Driver# 8 需要配置时区:serverTimezone=UTCspring.datasource.driver-class-name=com.mysql.cj.jdbc.Driverspring...
} else if (this.sqlSessionTemplate != null) { if (explicitFactoryUsed) { LOGGER.warn( () -> "Cannot use both: sqlSessionTemplate and sqlSessionFactory together. sqlSessionFactory is ignored."); } definition.getPropertyValues().add("sqlSessionTemplate", this.sqlSessionTemplate); ...