问题描述
入坑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);}
}
即:
通过以上修正问题即可得到解决