SSM+MybatisPlu整合时在MybatisPlus中在mapper.xml中编写原生sql总是报一个
包扫描也写了
你看看有没有这个方法,而且确保文件里的文字没有输入错误。
你的mapper里(xml或java)里没有getById这个方法
检查一下你的大小写是不是一样.
把sql语句打印出来 你就知道了 我跟你同样错误 我只执行delete 发现 我的 delete from user where id=3 编译成 delete from user where null=?
配置文件中这么写
#mybatis
mybatis-plus:
mapper-locations: classpath*:/mapper/*.xml
我也遇到了这个问题:
两种解决方法:我试了有效
第一:在pom.xml文件中添加
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
</resources>
</build>
第二种就是在resource文件下创建一个mapper,把xml文件放到这个文件中
@飞翔IT 老哥说的不错,我把原来的mybatis的这mapper-locations换成mybatis-plus就欧克了,哈哈哈哈,thank you
mybatisplus中提供的默认不需要写的方法叫selectById,而不是getById