Resolved versions for app (26.1.0) and test app (27.1.1) differ. 异常处理

Error:Execution failed for task ':app:preDebugAndroidTestBuild'.
> Conflict with dependency 'com.android.support:support-annotations' in project ':app'. Resolved versions for app (26.1.0) and test app (27.1.1) differ. See https://d.android.com/r/tools/test-apk-dependency-conflicts.html for details.

 

解决办法如下:

Model的   build.gradle里面 假如如下代码:

 

android {

......
.......
 
    configurations.all {
        resolutionStrategy.force 'com.android.support:support-annotations:26.1.0'
    }
}

 

这个错误通常是因为MyBatis找不到或无法匹配接口方法和XML映射文件中的语句引起的。解决此问题的步骤如下: 1.检查mapper接口的包路径和mapper配置文件中的namespace是否匹配。 2.检查mapper配置文件中是否存在与接口方法名称相同的语句。 3.检查mapper接口方法的参数类型是否与mapper配置文件中的语句参数类型匹配。 4.检查mapper配置文件中的语句是否正确,例如语句中的表名、列名是否正确。 以下是可能解决此问题的代码示例: 1.检查mapper接口的包路径和mapper配置文件中的namespace是否匹配。 ```xml <!-- mapper配置文件 --> <mapper namespace="com.test.mapper.UserMapper"> <select id="selectList" resultType="com.test.entity.User"> select * from user </select> </mapper> // mapper接口 package com.test.mapper; public interface UserMapper { List<User> selectList(); } ``` 2.检查mapper配置文件中是否存在与接口方法名称相同的语句。 ```xml <!-- mapper配置文件 --> <mapper namespace="com.test.mapper.UserMapper"> <select id="selectList" resultType="com.test.entity.User"> select * from user </select> <select id="selectListById" resultType="com.test.entity.User"> select * from user where id = #{id} </select> </mapper> // mapper接口 package com.test.mapper; public interface UserMapper { List<User> selectList(); } ``` 3.检查mapper接口方法的参数类型是否与mapper配置文件中的语句参数类型匹配。 ```xml <!-- mapper配置文件 --> <mapper namespace="com.test.mapper.UserMapper"> <select id="selectListById" resultType="com.test.entity.User"> select * from user where id = #{id} </select> </mapper> // mapper接口 package com.test.mapper; public interface UserMapper { User selectListById(Long id); } ``` 4.检查mapper配置文件中的语句是否正确,例如语句中的表名、列名是否正确。 ```xml <!-- mapper配置文件 --> <mapper namespace="com.test.mapper.UserMapper"> <select id="selectList" resultType="com.test.entity.User"> select * from users </select> </mapper> // mapper接口 package com.test.mapper; public interface UserMapper { List<User> selectList(); } ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值