第一个mapper报错了,是什么原因,求解
package cn.tedu.coolshark.controller;
import cn.tedu.coolshark.entity.Product;
import cn.tedu.coolshark.mapper.ProductMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Date;
@RestController
public class ProductController {
@Autowired
ProductMapper mapper;
@RequestMapping("/product/insert")
public void insert(@RequestBody Product product){
System.out.println("product = " + product);
//设置时间
product.setCreated(new Date());
mapper.insert(product);
}
}
启动类上加上@MapperScan("mapper包所在的路径"),把mapper加入到容器中
一般controller不会直接调用mapper,不符合规范
错误详情呢
报错信息发一下