gpt4 book ai didi

java - 'tablename' 中名为 'class java.lang.String' 的属性没有 getter

转载 作者:行者123 更新时间:2023-11-29 06:29:43 24 4
gpt4 key购买 nike

当我使用 mybatis 时,出现错误 There is no getter for property named 'tablename' in 'class java.lang.String'

我的映射器 xml 是这样的:

<mapper namespace="com.company.mapper.BasicMapper">
<update id="dropTable" parameterType="String">
DROP TABLE ${tablename}
</update>
</mapper>

界面是这样的:

public interface BasicMapper {
void dropTable(String tablename);
}

我是这样使用的:

public void dropTable(String tablename) {
basicMapper.dropTable(tablename);
}

我尝试用 #{tablename} 替换 ${tablename},但没有帮助。我怎样才能让它发挥作用?

最佳答案

对参数使用以下注解:

public interface BasicMapper {
void dropTable(@Param("tablename") String tablename);
}

关于java - 'tablename' 中名为 'class java.lang.String' 的属性没有 getter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38948298/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com