1、整合hibernate
***************************
APPLICATION FAILED TO START
***************************
Description:
Field userRepository in boottest.MainController required a bean of type 'withhibernate.UserRepository' that could not be found.
Action:
Consider defining a bean of type 'withhibernate.UserRepository' in your configuration.
问题描述:根据spring boot官网做些小东西,spring boot使用hibernate与mysql整合时,按照例子做好之后,没问题,当我把User、UserRepository单独放入一个withhibernate包下时,发生这种错误,字面意思就是找不到这个bean,基本定位是scan(扫描)没有找到,判定少注解
解决方式:
在注入方,添加注解扫描
@Controller
@RequestMapping(path="/demo")
@ComponentScan({"withhibernate"})
@EntityScan("withhibernate")
@EnableJpaRepositories("withhibernate")
public class MainController {
@Autowired
private UserRepository userRepository;
2、整合mybatis时
controller上面添加@MapperScan ("withmybatis")