SpringBoot整合Mybatis出现的错误
来源:互联网 发布:java用ftp上传文件 编辑:程序博客网 时间:2024/06/02 00:03
代码错误如下:
java.lang.IllegalArgumentException: At least one base package must be specifiedat org.springframework.util.Assert.notEmpty(Assert.java:228) ~[spring-core-4.3.7.RELEASE.jar:4.3.7.RELEASE]at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:269) ~[spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]at org.mybatis.spring.mapper.ClassPathMapperScanner.doScan(ClassPathMapperScanner.java:164) ~[mybatis-spring-1.3.0.jar:1.3.0]at org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration$AutoConfiguredMapperScannerRegistrar.registerBeanDefinitions(MybatisAutoConfiguration.java:177) ~[mybatis-spring-boot-autoconfigure-1.1.1.jar:1.1.1]at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsFromRegistrars(ConfigurationClassBeanDefinitionReader.java:352) ~[spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:143) ~[spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:116) ~[spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:320) ~[spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:228) ~[spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:270) ~[spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:93) ~[spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:686) ~[spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:524) ~[spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737) [spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370) [spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) [spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162) [spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151) [spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]at SpringBootApplication.main(SpringBootApplication.java:11) [classes/:na]2017-12-13 22:36:35.606 INFO 4588 --- [ main] ationConfigEmbeddedWebApplicationContext : Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@2bbaf4f0: startup date [Wed Dec 13 22:36:32 CST 2017]; root of context hierarchy2017-12-13 22:36:35.609 WARN 4588 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception thrown from LifecycleProcessor on context closejava.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via the context: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@2bbaf4f0: startup date [Wed Dec 13 22:36:32 CST 2017]; root of context hierarchyat org.springframework.context.support.AbstractApplicationContext.getLifecycleProcessor(AbstractApplicationContext.java:417) [spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1002) [spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:961) [spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]at org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:794) [spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]at org.springframework.boot.SpringApplication.run(SpringApplication.java:325) [spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162) [spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151) [spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]at SpringBootApplication.main(SpringBootApplication.java:11) [classes/:na]2017-12-13 22:36:35.610 ERROR 4588 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Destroy method on bean with name 'org.springframework.boot.autoconfigure.internalCachingMetadataReaderFactory' threw an exceptionjava.lang.IllegalStateException: ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@2bbaf4f0: startup date [Wed Dec 13 22:36:32 CST 2017]; root of context hierarchyat org.springframework.context.support.AbstractApplicationContext.getApplicationEventMulticaster(AbstractApplicationContext.java:404) [spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]at org.springframework.context.support.ApplicationListenerDetector.postProcessBeforeDestruction(ApplicationListenerDetector.java:97) ~[spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:253) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE]
错误原因:没有在主函数的类中对Mapper层进行扫描。
解决:加上对mapper层的扫描MapperScan
@ComponentScan(basePackages = { "cn.iponkan.controller"})@MapperScan(basePackages = {"cn.iponkan.mapper"})@EnableAutoConfigurationpublic class SpringBootApplication { public static void main(String[] args){ SpringApplication.run(SpringBootApplication.class,args); }}
阅读全文
0 0
- SpringBoot整合Mybatis出现的错误
- springboot与mybatis的整合
- springboot与mybatis的整合
- springBoot整合myBatis错误:java.lang.NoSuchMethodException
- Springboot整合mybatis出现无法注入mapper接口的问题处理
- 关于IDEA工具在springboot整合mybatis中出现的Invalid bound statement (not found)问题
- Springboot 整合 Mybatis 的完整 Web 案例
- Springboot 整合 Mybatis 的完整 Web 案例
- springboot整合mybatis最简单的例子
- Springboot 整合 Mybatis 的完整 Web 案例
- Springboot整合Mybatis的CallSettersOnNulls配置问题
- 简单的SpringBoot+Mybatis框架整合
- Springboot 整合 Mybatis 的完整 Web 案例
- 一个简单的SpringBoot整合Mybatis项目
- Springboot 整合 Mybatis 的完整 Web 案例
- springboot 整合mybatis 遇到的问题
- 关于Springboot整合mybatis启动的问题
- springboot整合mybatis的三种方式
- 利用线上yum源,制作本地yum源
- 模糊控制系统模糊控制器模块(一)---模糊化
- 335x uboot 看门狗喂狗
- TCP/UDP
- mybatis中的#和$的区别
- SpringBoot整合Mybatis出现的错误
- 用两个线程玩猜数字游戏,第一个线程负责随机给出1~100之间的一个整数,第二个线程负责猜出这个数。要求每当第二个线程给出自己的猜测后,第一个线程都会提示“猜小了”、“猜大了”或“猜对
- dubbo简介
- MFC显示JPG格式的图片(2-1)
- Android Studio打包apk
- 12Linux安装-CRT安装配置
- 机器学习 矩阵奇异值分解(SVD)及其应用
- C++STL 第十次实验(词频统计)
- mybatis传入多个参数