|
|
@@ -3,6 +3,7 @@ package com.ruoyi;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
|
+import com.ruoyi.common.utils.sm4.SM4Util;
|
|
|
import com.ruoyi.model.dpp.dal.dataobject.etl.DppEtlTaskDO;
|
|
|
import com.ruoyi.model.etl.mapper.DppEtlTaskMapper;
|
|
|
import com.ruoyi.model.etl.mapper.TestDppEtlTaskMapper;
|
|
|
@@ -20,180 +21,13 @@ import java.util.Map;
|
|
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
|
|
|
|
|
|
|
|
-@SpringBootTest(classes = RuoYiApplication.class,webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
|
|
+@SpringBootTest(classes = RuoYiApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
|
|
@RunWith(SpringRunner.class)
|
|
|
public class JasyptTest {
|
|
|
|
|
|
|
|
|
@Test
|
|
|
- public void comprehensiveDiagnosis() {
|
|
|
- System.out.println("=== 全面诊断 MyBatis-Plus Join 问题 ===");
|
|
|
-
|
|
|
- // 1. 检查上下文
|
|
|
- assertNotNull(applicationContext);
|
|
|
-
|
|
|
- // 2. 检查 Mapper 注入
|
|
|
- assertNotNull(dppEtlTaskMapper);
|
|
|
- System.out.println("✅ Mapper 注入成功");
|
|
|
-
|
|
|
- // 3. 检查 BaseMapperX 继承
|
|
|
- testBaseMapperXInheritance();
|
|
|
-
|
|
|
- // 4. 检查 MyBatis-Plus Join 配置
|
|
|
- checkMyBatisPlusJoinAutoConfiguration();
|
|
|
-
|
|
|
- // 5. 测试其他 MPJ 方法(如果 selectJoinPage 不行)
|
|
|
- testOtherMPJMethods();
|
|
|
- }
|
|
|
-
|
|
|
- private void testOtherMPJMethods() {
|
|
|
- System.out.println("=== 测试其他 MyBatis-Plus Join 方法 ===");
|
|
|
-
|
|
|
- MPJLambdaWrapper<DppEtlTaskDO> wrapper = new MPJLambdaWrapper<>();
|
|
|
- wrapper.eq(DppEtlTaskDO::getDelFlag, "0");
|
|
|
-
|
|
|
- // 测试 selectJoinList
|
|
|
- try {
|
|
|
- List<DppEtlTaskDO> result = dppEtlTaskMapper.selectJoinList(DppEtlTaskDO.class, wrapper);
|
|
|
- System.out.println("✅ selectJoinList 工作正常,结果数量: " + result.size());
|
|
|
- } catch (Exception e) {
|
|
|
- System.out.println("❌ selectJoinList 也失败: " + e.getMessage());
|
|
|
- }
|
|
|
-
|
|
|
- // 测试 selectJoinOne
|
|
|
- try {
|
|
|
- DppEtlTaskDO result = dppEtlTaskMapper.selectJoinOne(DppEtlTaskDO.class, wrapper);
|
|
|
- System.out.println("✅ selectJoinOne 工作正常");
|
|
|
- } catch (Exception e) {
|
|
|
- System.out.println("❌ selectJoinOne 失败: " + e.getMessage());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- @Test
|
|
|
- public void checkMyBatisPlusJoinAutoConfiguration() {
|
|
|
- System.out.println("=== 检查 MyBatis-Plus Join 自动配置 ===");
|
|
|
-
|
|
|
- try {
|
|
|
- // 检查 MPJInterceptor 是否存在
|
|
|
- Object mpjInterceptor = applicationContext.getBean("mpjInterceptor");
|
|
|
- System.out.println("✅ MPJInterceptor 存在: " + mpjInterceptor.getClass().getName());
|
|
|
- } catch (Exception e) {
|
|
|
- System.out.println("❌ MPJInterceptor 不存在: " + e.getMessage());
|
|
|
- }
|
|
|
-
|
|
|
- // 检查 MyBatis-Plus Join 相关的 Bean
|
|
|
- String[] beanNames = applicationContext.getBeanNamesForType(com.github.yulichang.interceptor.MPJInterceptor.class);
|
|
|
- System.out.println("找到的 MPJInterceptor Beans: " + Arrays.toString(beanNames));
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- @Test
|
|
|
- public void testBaseMapperXInheritance() {
|
|
|
- System.out.println("=== 验证 BaseMapperX 继承关系 ===");
|
|
|
-
|
|
|
- // 检查 Mapper 的实际类型
|
|
|
- Class<?> mapperClass = dppEtlTaskMapper.getClass();
|
|
|
- System.out.println("Mapper 实际类: " + mapperClass.getName());
|
|
|
-
|
|
|
- // 检查实现的接口
|
|
|
- Class<?>[] interfaces = mapperClass.getInterfaces();
|
|
|
- for (Class<?> iface : interfaces) {
|
|
|
- System.out.println("实现的接口: " + iface.getName());
|
|
|
- }
|
|
|
-
|
|
|
- // 检查是否是 MPJBaseMapper 的实例
|
|
|
- boolean isMPJBaseMapper = dppEtlTaskMapper instanceof com.github.yulichang.base.MPJBaseMapper;
|
|
|
- System.out.println("是否是 MPJBaseMapper 实例: " + isMPJBaseMapper);
|
|
|
-
|
|
|
- // 尝试通过反射查看方法
|
|
|
- try {
|
|
|
- java.lang.reflect.Method method = dppEtlTaskMapper.getClass().getMethod("selectJoinPage",
|
|
|
- com.baomidou.mybatisplus.core.metadata.IPage.class, Class.class, com.github.yulichang.wrapper.MPJLambdaWrapper.class);
|
|
|
- System.out.println("找到 selectJoinPage 方法: " + method);
|
|
|
- } catch (NoSuchMethodException e) {
|
|
|
- System.out.println("未找到 selectJoinPage 方法");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- @Autowired(required = false) // 设置为非必需,避免启动失败
|
|
|
- private TestDppEtlTaskMapper dppEtlTaskMapper;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private ApplicationContext applicationContext;
|
|
|
-
|
|
|
- @Test
|
|
|
- public void testMyBatisPlusJoinConfiguration() {
|
|
|
- System.out.println("=== 开始诊断 Mapper 注入问题 ===");
|
|
|
-
|
|
|
- // 检查 ApplicationContext 是否正常
|
|
|
- System.out.println("ApplicationContext: " + (applicationContext != null ? "正常" : "null"));
|
|
|
-
|
|
|
- // 检查所有 Bean
|
|
|
- String[] beanNames = applicationContext.getBeanDefinitionNames();
|
|
|
- boolean foundMapper = false;
|
|
|
- for (String beanName : beanNames) {
|
|
|
- if (beanName.toLowerCase().contains("dppetltaskmapper") ||
|
|
|
- beanName.contains("DppEtlTaskMapper")) {
|
|
|
- System.out.println("找到 Mapper Bean: " + beanName);
|
|
|
- foundMapper = true;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (!foundMapper) {
|
|
|
- System.out.println("未找到 DppEtlTaskMapper Bean");
|
|
|
- // 检查所有 Mapper 类型的 Bean
|
|
|
- try {
|
|
|
- Map<String, Object> mappers = applicationContext.getBeansWithAnnotation(org.apache.ibatis.annotations.Mapper.class);
|
|
|
- System.out.println("找到的 Mapper Beans: " + mappers.keySet());
|
|
|
- } catch (Exception e) {
|
|
|
- System.out.println("获取 Mapper Beans 时出错: " + e.getMessage());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 检查 Mapper 是否注入
|
|
|
- if (dppEtlTaskMapper == null) {
|
|
|
- System.out.println("❌ DppEtlTaskMapper 注入失败");
|
|
|
- // 尝试手动获取
|
|
|
- try {
|
|
|
- TestDppEtlTaskMapper mapper = applicationContext.getBean(TestDppEtlTaskMapper.class);
|
|
|
- System.out.println("✅ 通过 ApplicationContext 获取 Mapper 成功");
|
|
|
- dppEtlTaskMapper = mapper;
|
|
|
- } catch (Exception e) {
|
|
|
- System.out.println("❌ 通过 ApplicationContext 获取 Mapper 也失败: " + e.getMessage());
|
|
|
- return; // 如果获取不到,直接返回
|
|
|
- }
|
|
|
- } else {
|
|
|
- System.out.println("✅ DppEtlTaskMapper 注入成功");
|
|
|
- }
|
|
|
-
|
|
|
- // 如果 Mapper 存在,继续测试
|
|
|
- if (dppEtlTaskMapper != null) {
|
|
|
- testSelectJoinPage();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void testSelectJoinPage() {
|
|
|
- System.out.println("=== 开始测试 selectJoinPage 方法 ===");
|
|
|
-
|
|
|
- MPJLambdaWrapper<DppEtlTaskDO> wrapper = new MPJLambdaWrapper<>();
|
|
|
- wrapper.eq(DppEtlTaskDO::getDelFlag, "0");
|
|
|
-
|
|
|
- try {
|
|
|
- IPage<DppEtlTaskDO> result = dppEtlTaskMapper.selectJoinPage(
|
|
|
- new Page<>(1, 5),
|
|
|
- DppEtlTaskDO.class,
|
|
|
- wrapper
|
|
|
- );
|
|
|
- System.out.println("✅ MyBatis-Plus Join 工作正常!");
|
|
|
- System.out.println("查询到 " + result.getRecords().size() + " 条记录");
|
|
|
- } catch (Exception e) {
|
|
|
- System.out.println("❌ MyBatis-Plus Join 配置有问题: " + e.getMessage());
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
+ public void test() {
|
|
|
+ System.out.println(SM4Util.selfCheck());
|
|
|
}
|
|
|
}
|