关于使用@Mapping注解无效的原因

使用@Mapping会报出如下错误

当出现

The injection point has the following annotations:

- @org.springframework.beans.factory.annotation.Autowired(required=true)

Action:

Consider defining a bean of type '****.SysUserMapper' in your configuration.

错误时,一般来说,都是注解无效。
而这里无效的原因,有可能为mybatis和mybatis-spring的版本不够高

因为  Mapper来自mybatis-3.5.3.jar包       MapperScan来自mybatis-spring-2.0.3.jar包

还有可能@Mapping引入不到为@MappingScan的原因

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
@Mapping注解Spring MVC框架中有着广泛的应用,它可以用于将HTTP请求映射到处理程序类或处理程序方法上。具体的使用方式和说明如下: 1. 用于类级别 在类级别上使用@Mapping注解表示该类中所有方法的映射路径的公共前缀。例如: ``` @Controller @RequestMapping("/user") public class UserController { // ... } ``` 上述代码表示UserController类中所有方法的映射路径都以/user为前缀。 2. 用于方法级别 在方法级别上使用@Mapping注解表示该方法的具体映射路径。例如: ``` @Controller @RequestMapping("/user") public class UserController { @RequestMapping("/list") public String listUsers(Model model) { // ... } } ``` 上述代码表示listUsers方法的映射路径是/user/list。 3. 指定HTTP请求方法类型 @Mapping注解可以指定HTTP请求的方法类型,例如: ``` @RequestMapping(value = "/users", method = RequestMethod.GET) public List<User> getUsers() { // ... } ``` 上述代码表示getUsers方法只接受GET请求。 4. 指定请求参数和请求头信息 @Mapping注解可以指定HTTP请求的参数和头信息,例如: ``` @RequestMapping(value = "/user", params = "id=1", headers = "content-type=text/plain") public String getUser() { // ... } ``` 上述代码表示getUser方法只接受id参数值为1,content-type头信息为text/plain的HTTP请求。 5. 支持Ant风格的URL路径匹配 @Mapping注解支持Ant风格的URL路径匹配,例如: ``` @RequestMapping("/user/*") public String handleRequest(HttpServletRequest request, HttpServletResponse response) { // ... } ``` 上述代码表示匹配以/user/开头的所有URL路径。 总之,@Mapping注解Spring MVC框架中非常重要的注解,它可以帮助我们将HTTP请求映射到对应的处理程序方法上,从而实现请求处理和响应的功能。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值