SpringBoot整合Mybatis

65 阅读1分钟

java.lang.Object.wait(Native Method)
java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:144)
com.mysql.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:43)
2021-10-28 21:53:46.207  INFO 1640 --- [           main] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-10-28 21:53:46.228 ERROR 1640 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

Field usersMapper in com.tong.springbootmybatisdemo.service.impl.UsersServiceImpl required a bean of type 'com.tong.springbootmybatisdemo.mapper.UsersMapper' that could not be found.

The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)


Action:

Consider defining a bean of type 'com.tong.springbootmybatisdemo.mapper.UsersMapper' in your configuration.

________________________________

public class SpringbootmybatisdemoApplication {

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

}

添加

@MapperScan("com.tong.springbootmybatisdeom.mapper")//指定扫描接口与映射配置文件的包名

——————————————————————————————————

最后

@SpringBootApplication
@MapperScan("com.tong.springbootmybatisdeom.mapper")//指定扫描接口与映射配置文件的包名
public class SpringbootmybatisdemoApplication {

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

}