最近公司在做框架升级,要旧项目代码迁移到新框架,迁移后发现报错:
List<Map<String, Object>> getTypeStat(String adcode,String aoiId);
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter 'aoiId' not found. Available parameters are [arg1, arg0, param1, param2]
经过一番研究发现需要在maven中增加一个配置
<parameters>true</parameters>
就可以解决问题,具体配置如下:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
<parameters>true</parameters>
</configuration>
</plugin>
原因分析:
对比新旧框架后发现,旧框架没有报错是因为父工程直接继承了springboot,这种方式会默认配置<parameters>true</parameters>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
</parent>
但新框架父工程继承了公司自有工程,而springboot是通过依赖方式引用的,不会默认配置<parameters>true</parameters>,导致报错
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>
觉得有用,求点个赞!