关于mybatis 找不到parameter map java.util.Map

本文记录了一次使用JUnit进行测试时遇到的关于MyBatis的错误:Could not find parameter map java.util.Map。经过排查发现是由于旧版的parameterMap配置不再支持,而应该使用parameterType来替代。

今天junit 测试的时候 一直报错

org.apache.ibatis.builder.IncompleteElementException: Could not find parameter map java.util.Map

Caused by: org.apache.ibatis.builder.IncompleteElementException: Could not find parameter map java.util.Map

Caused by: java.lang.IllegalArgumentException: Parameter Maps collection does not contain value for java.util.Map

查看了 xml 文件没有找到错误,更改了别名也不起作用,

 

百度查找之后发现是 parameterMap已经取消了,需要使用parameterType

 

大意了!!!!

System.out.println("======offer_code:"+map.get("offer_code")); System.out.println("======keyword:"+keyword); offerInfo.setOfferCode((String) map.get("offer_code")); offerInfo.setKeyword(keyword); offerInfo.setSku((String) map.get("sku")); String brand = (String) map.get("brand"); String name = (String) map.get("name"); offerInfo.setBrand((String) map.get("brand")); offerInfo.setName((String) map.get("name")); Map<String, String> map1 = (Map<String, String>) map.get("product_rating"); List<String> imageKeys = (List<String>) map.get("image_keys"); StringBuilder imageUrl = new StringBuilder("https://f.nooncdn.com/p/"); imageUrl.append(imageKeys.get(0)); offerInfo.setTitle(brand + " " + name); Integer inte = Integer.parseInt(map1.get("count")); 这里代码报错了map1是一个map集合拿到的值是"product_rating": { "best_rating": 5, "count": 406, "value": 4.8 },为啥这里会出现类型转换异常:java.lang.ClassCastException: class java.lang.Integer cannot be cast to class java.lang.String (java.lang.Integer and java.lang.String are in module java.base of loader 'bootstrap') at com.ruoyi.system.domain.OfferInfo.toOfferInfo(OfferInfo.java:46) at com.ruoyi.web.controller.tool.DataProcessService.lambda$batchSave$2(DataProcessService.java:238) at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921) at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682) at com.ruoyi.web.controller.tool.DataProcessService.batchSave(DataProcessService.java:238) at com.
05-31
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.boot.context.properties.ConfigurationPropertiesBindException: Error creating bean with name 'mybatis-plus-com.baomidou.mybatisplus.autoconfigure.MybatisPlusProperties': Could not bind properties to 'MybatisPlusProperties' : prefix=mybatis-plus, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'mybatis-plus.global-config.sql-injector' to com.baomidou.mybatisplus.core.injector.ISqlInjector at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:729) at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:192) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1270) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1127) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:541) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:501) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:760) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:869) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395) at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1255) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1243) at com.stylefeng.guns.authsystem.AuthSystemApplication.main(AuthSystemApplication.java:39) Caused by: org.springframework.boot.context.properties.ConfigurationPropertiesBindException: Error creating bean with name 'mybatis-plus-com.baomidou.mybatisplus.autoconfigure.MybatisPlusProperties': Could not bind properties to 'MybatisPlusProperties' : prefix=mybatis-plus, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'mybatis-plus.global-config.sql-injector' to com.baomidou.mybatisplus.core.injector.ISqlInjector at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.bind(ConfigurationPropertiesBindingPostProcessor.java:109) at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.postProcessBeforeInitialization(ConfigurationPropertiesBindingPostProcessor.java:93) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:422) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1694) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:579) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:501) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:251) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1065) at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:815) at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:721) ... 19 more Caused by: org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'mybatis-plus.global-config.sql-injector' to com.baomidou.mybatisplus.core.injector.ISqlInjector at org.springframework.boot.context.properties.bind.Binder.handleBindError(Binder.java:250) at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:226) at org.springframework.boot.context.properties.bind.Binder.lambda$bindBean$4(Binder.java:334) at org.springframework.boot.context.properties.bind.JavaBeanBinder.bind(JavaBeanBinder.java:73) at org.springframework.boot.context.properties.bind.JavaBeanBinder.bind(JavaBeanBinder.java:62) at org.springframework.boot.context.properties.bind.JavaBeanBinder.bind(JavaBeanBinder.java:54) at org.springframework.boot.context.properties.bind.Binder.lambda$null$5(Binder.java:342) at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) at java.util.ArrayList$ArrayListSpliterator.tryAdvance(ArrayList.java:1361) at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126) at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:499) at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:486) at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472) at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152) at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464) at org.springframework.boot.context.properties.bind.Binder.lambda$bindBean$6(Binder.java:343) at org.springframework.boot.context.properties.bind.Binder$Context.withIncreasedDepth(Binder.java:442) at org.springframework.boot.context.properties.bind.Binder$Context.withBean(Binder.java:428) at org.springframework.boot.context.properties.bind.Binder$Context.access$400(Binder.java:382) at org.springframework.boot.context.properties.bind.Binder.bindBean(Binder.java:340) at org.springframework.boot.context.properties.bind.Binder.bindObject(Binder.java:279) at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:221) at org.springframework.boot.context.properties.bind.Binder.lambda$bindBean$4(Binder.java:334) at org.springframework.boot.context.properties.bind.JavaBeanBinder.bind(JavaBeanBinder.java:73) at org.springframework.boot.context.properties.bind.JavaBeanBinder.bind(JavaBeanBinder.java:62) at org.springframework.boot.context.properties.bind.JavaBeanBinder.bind(JavaBeanBinder.java:54) at org.springframework.boot.context.properties.bind.Binder.lambda$null$5(Binder.java:342) at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) at java.util.ArrayList$ArrayListSpliterator.tryAdvance(ArrayList.java:1361) at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126) at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:499) at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:486) at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472) at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152) at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464) at org.springframework.boot.context.properties.bind.Binder.lambda$bindBean$6(Binder.java:343) at org.springframework.boot.context.properties.bind.Binder$Context.withIncreasedDepth(Binder.java:442) at org.springframework.boot.context.properties.bind.Binder$Context.withBean(Binder.java:428) at org.springframework.boot.context.properties.bind.Binder$Context.access$400(Binder.java:382) at org.springframework.boot.context.properties.bind.Binder.bindBean(Binder.java:340) at org.springframework.boot.context.properties.bind.Binder.bindObject(Binder.java:279) at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:221) at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:210) at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:192) at org.springframework.boot.context.properties.ConfigurationPropertiesBinder.bind(ConfigurationPropertiesBinder.java:82) at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.bind(ConfigurationPropertiesBindingPostProcessor.java:106) ... 33 more Caused by: org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.lang.String] to type [com.baomidou.mybatisplus.core.injector.ISqlInjector] at org.springframework.core.convert.support.GenericConversionService.handleConverterNotFound(GenericConversionService.java:321) at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:194) at org.springframework.boot.context.properties.bind.BindConverter$CompositeConversionService.convert(BindConverter.java:162) at org.springframework.boot.context.properties.bind.BindConverter.convert(BindConverter.java:96) at org.springframework.boot.context.properties.bind.BindConverter.convert(BindConverter.java:88) at org.springframework.boot.context.properties.bind.Binder.bindProperty(Binder.java:324) at org.springframework.boot.context.properties.bind.Binder.bindObject(Binder.java:267) at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:221) ... 79 more
12-09
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值