开始,加了这个注解,一定不要加这段代码 这个注解是排除自动注入 导致mapper注入不进去。
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'areaDicMapper' defined in file [/home/tongning/ideaprojects/foooooot/dao/target/classes/com/travel/dao/areadic/AreaDicMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required
原来是没有在application.properties中加spring.datasource的属性报下面的错。
但是奇怪的是我另外一个模块没有加,不会报错。(用的是Bean注入的c3p0)。那么我用了内置的,c3p0就失效了。等找到解决办法再编辑吧。
If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).
本文分析了在Spring Boot项目中使用MyBatis时遇到的Mapper注入失败问题,探讨了原因在于自动配置冲突及数据源设置缺失,并提供了解决方案,包括正确配置数据源和调整@SpringBootApplication注解的exclude属性。
2535

被折叠的 条评论
为什么被折叠?



