{"record":{"id":"a3443d6ef017db1e","repo":"baomidou/mybatis-plus","slug":"liketable-and-notliketable-configurations-are","errorCode":null,"errorMessage":"`likeTable` and `notLikeTable` configurations are mutually exclusive and cannot be used simultaneously.","messagePattern":"`likeTable` and `notLikeTable` configurations are mutually exclusive and cannot be used simultaneously\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/config/StrategyConfig.java","lineNumber":273,"sourceCode":"     * @since 3.3.2\n     */\n    public boolean startsWithTablePrefix(@NotNull String tableName) {\n        return this.tablePrefix.stream().anyMatch(tableName::startsWith);\n    }\n\n    /**\n     * 验证配置项\n     *\n     * @since 3.5.0\n     */\n    public void validate() {\n        boolean isInclude = !this.getInclude().isEmpty();\n        boolean isExclude = !this.getExclude().isEmpty();\n        if (isInclude && isExclude) {\n            throw new IllegalArgumentException(\"`include` and `exclude` configurations are mutually exclusive and cannot be used simultaneously.\");\n        }\n        if (this.getNotLikeTable() != null && this.getLikeTable() != null) {\n            throw new IllegalArgumentException(\"`likeTable` and `notLikeTable` configurations are mutually exclusive and cannot be used simultaneously.\");\n        }\n    }\n\n    /**\n     * 包含表名匹配\n     *\n     * @param tableName 表名\n     * @return 是否匹配\n     * @since 3.5.0\n     */\n    public boolean matchIncludeTable(@NotNull String tableName) {\n        return matchTable(tableName, this.getInclude());\n    }\n\n    /**\n     * 排除表名匹配\n     *\n     * @param tableName 表名","sourceCodeStart":255,"sourceCodeEnd":291,"githubUrl":"https://github.com/baomidou/mybatis-plus/blob/bf67d907478c724120bf76292da54abf9e73c2b3/mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/config/StrategyConfig.java#L255-L291","documentation":"StrategyConfig.validate() throws IllegalArgumentException when both likeTable and notLikeTable are set. LIKE-matching and NOT-LIKE-matching table filters are mutually exclusive by design; validate() enforces this before generation starts.","triggerScenarios":"Configuring StrategyConfig with both .likeTable(new LikeTable(\"user\")) and .notLikeTable(new LikeTable(\"tmp\")) (or setters setLikeTable/setNotLikeTable), then calling generate().","commonSituations":"Migrating an older config that used likeTable and later adding notLikeTable to skip temp tables, without removing the old setting; chaining fluent builder calls copied from documentation samples that each use a different filter.","solutions":["Delete one of the two: keep likeTable for an allow-pattern or notLikeTable for a deny-pattern, never both.","If you need pattern allow + pattern deny, switch to explicit include/exclude lists computed from DatabaseMetaData# getTables before generation.","Add an early strategyConfig.validate() call or unit test to surface the conflict at startup."],"exampleFix":"// before\nstrategy.likeTable(new LikeTable(\"user\"));\nstrategy.notLikeTable(new LikeTable(\"tmp\")); // conflict\n\n// after\nstrategy.notLikeTable(new LikeTable(\"tmp\")); // single pattern filter only","handlingStrategy":"validation","validationCode":"if (strategyConfig.getLikeTable() != null && strategyConfig.getNotLikeTable() != null) {\n    throw new IllegalArgumentException(\"choose likeTable OR notLikeTable\");\n}\nstrategyConfig.validate();","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use exactly one pattern filter; express anything more complex with include/exclude lists.","Fail fast by calling validate() in a config unit test.","When migrating configs, grep for both setters to ensure the old one was removed."],"tags":["mybatis-plus","code-generator","configuration","validation"],"backgroundTag":null,"analyzedSha":"bf67d907478c724120bf76292da54abf9e73c2b3","analyzedAt":"2026-08-14T15:17:09.543Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}