Property ‘sqlSessionFactory‘ or ‘sqlSessionTemplate‘ are required 问题解决

以下是报错日志

image

解决方案

确认以下配置是否都存在:

1、配置文件有写mybatis配置

image

2、启动类里加上Mapper扫描的注解(指向自己mapper存放的位置)

image

3、删除SpringBootApplication注解的exclude属性:

@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class, DataSourceTransactionManagerAutoConfiguration.class })
public class LovecardApplication {

    public static void main(String[] args) {
        SpringApplication.run(LovecardApplication.class, args);
    }

}


中的SpringBootApplication注解改为

@SpringBootApplication
public class LovecardApplication {

    public static void main(String[] args) {
        SpringApplication.run(LovecardApplication.class, args);
    }

}

再次启动
无报错
image

文章来源:https://blog.csdn.net/igray_xl/article/details/119347520

posted @ 2023-07-03 16:28  Lafite-1820  阅读(648)  评论(0编辑  收藏  举报