问题描述

     入坑springcloud的时候,启动报错,提示 Caused by: java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required,如下图:
在这里插入图片描述

问题分析

     springboot启动方法上面的包名注解写法有误,就会造成以上错误如下所示的错误写法:
在这里插入图片描述

解决办法

     正确的写法应该是:

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.ComponentScan;

@SpringBootApplication
@ComponentScan(basePackages = {"com.microblog.mapper"})
public class BackendBlogApplication {

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

即:
在这里插入图片描述
通过以上修正问题即可得到解决

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐