spring boot mybatis-plus Error creating bean with name

jialiguo 2019-02-27 07:14:13

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sysMenuServiceImpl': Unsatisfied dependency expressed through field 'baseMapper'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sysMenuDaoI' defined in file [E:\Workspaces\IntelliJ\springboot\out\production\classes\org\jia\springboot\dao\SysMenuDaoI.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:596)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:374)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1378)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:575)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:498)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:846)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:863)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:316)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248)
at org.jia.springboot.App.main(App.java:29)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sysMenuDaoI' defined in file [E:\Workspaces\IntelliJ\springboot\out\production\classes\org\jia\springboot\dao\SysMenuDaoI.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1745)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:576)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:498)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:273)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1239)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1166)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:593)
... 19 common frames omitted
Caused by: java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required
at org.springframework.util.Assert.notNull(Assert.java:198)
at org.mybatis.spring.support.SqlSessionDaoSupport.checkDaoConfig(SqlSessionDaoSupport.java:123)
at org.mybatis.spring.mapper.MapperFactoryBean.checkDaoConfig(MapperFactoryBean.java:73)
at org.springframework.dao.support.DaoSupport.afterPropertiesSet(DaoSupport.java:44)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1804)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1741)
... 29 common frames omitted


Process finished with exit code 1



@SpringBootApplication
@EnableAsync // 开启异步调用 @Async可以设置某个函数是异步执行的
//方法前带 @Async ,相当于为这个方法重新开辟了单独线程进行执行 。思路:使用aop技术在运行时,创建一个单独线程进行执行
@MapperScan("org.jia.springboot.dao")
@Slf4j
public class App {

public static void main(String[] args) {
//整个程序的入口,启动springBoot项目(创建内置tomcat服务器,使用tomcat加载springmvc注解启动类)
SpringApplication.run(App.class, args);
log.info("========================启动完毕========================");
}
}


implementation('org.springframework.boot:spring-boot-starter-web')
testImplementation('org.springframework.boot:spring-boot-starter-test')
implementation('org.springframework.boot:spring-boot-starter-freemarker')
implementation('org.springframework.boot:spring-boot-starter-aop')
implementation('org.projectlombok:lombok:1.18.4')
//mybatisPlus 会自动的维护Mybatis 以及MyBatis-spring相关的依赖
implementation 'com.baomidou:mybatis-plus-boot-starter:3.1.0'
implementation 'com.baomidou:mybatis-plus:3.1.0'
implementation 'com.alibaba:druid-spring-boot-starter:1.1.10'
implementation 'mysql:mysql-connector-java:5.1.37'
//mp代码生成器使用
implementation 'org.apache.velocity:velocity-engine-core:2.0'
compile group: 'com.baomidou', name: 'mybatis-plus-generator', version: '3.0.7.1'
...全文
3103 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
zz90zz 2019-02-28
  • 打赏
  • 举报
回复
Error creating bean with name 'sysMenuServiceImpl': Unsatisfied dependency expressed through field 'baseMapper'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sysMenuDaoI' defined in file [E:\Workspaces\IntelliJ\springboot\out\production\classes\org\jia\springboot\dao\SysMenuDaoI.class]

SysMenuDaoI的命名是不是多了个I,改成SysMenuDao试试
jialiguo 2019-02-28
  • 打赏
  • 举报
回复
解决了 去掉了 mybatis-plus使用的 implementation 'org.apache.velocity:velocity-engine-core:2.0' 就可以了 ,难道有冲突吗? 怪事
十八道胡同 2019-02-28
  • 打赏
  • 举报
回复
E:\Workspaces\IntelliJ\springboot\out\production\classes\org\jia\springboot\dao\SysMenuDaoI.class 这个文件是SysMenuDaoI, 你要创建的bean名字是sysMenuServiceImpl, 最好把相关代码 贴出来
jialiguo 2019-02-27
  • 打赏
  • 举报
回复
server.port=8080
########################################################
### JDBC
### 数据库访问配置 主数据源默认是的
########################################################
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:7000/wstro?characterEncoding=UTF-8&useUnicode=true
#jdbc:mysql://127.0.0.1:7000/wstro?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8
spring.datasource.username=root
spring.datasource.password=
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
# 下面为连接池的补充设置,应用到上面所有数据源中
#初始化连接数量
spring.datasource.initialSize=5
#最小空闲连接
spring.datasource.minIdle=5
#最大连接数量
spring.datasource.maxActive=200
#超过时间限制是否回收
spring.datasource.removeAbandoned=true
#超时时间;单位为秒。180秒=3分钟
spring.datasource.removeAbandonedTimeout=180
#关闭abanded连接时输出错误日志
spring.datasource.logAbandoned=true
#获取连接等待超时的时间以毫秒为单位
spring.datasource.maxWait=60000
#间隔多久才进行一次检测,检测需要关闭的空闲连接(超过minEvictableIdleTimeMillis的关闭),单位是毫秒
spring.datasource.timeBetweenEvictionRunsMillis=60000
#一个连接在池中最小生存的时间,单位是毫秒
spring.datasource.minEvictableIdleTimeMillis=300000
#SQL查询,用来验证从连接池取出的连接,在将连接返回给调用者之前
spring.datasource.validationQuery=SELECT 1 FROM DUAL
#指明连接是否被空闲连接回收器(如果有)进行检验.
#如果检测失败,则连接将被从池中去除.
spring.datasource.testWhileIdle=true
#指明是否在从池中取出连接前进行检验,如果检验失败,则从池中去除连接并尝试取出另一个.
spring.datasource.testOnBorrow=false
#指明是否在归还到池中前进行检验
spring.datasource.testOnReturn=false
#是否缓存preparedStatement,在mysql下建议关闭。
poolPreparedStatements=false
maxPoolPreparedStatementPerConnectionSize=200
# 监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙
spring.datasource.filters=stat,wall,log4j
# 通过connectProperties属性来打开mergeSql功能;慢SQL记录
spring.datasource.connectionProperties=druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
#合并多个DruidDataSource的监控数据
#spring.datasource.useGlobalDataSourceStat=true
########################################################
###spring boot 编码属性配置
########################################################
spring.http.encoding.charset=UTF-8
spring.http.encoding.enabled=true
spring.http.encoding.force=true
spring.messages.encoding=UTF-8
#spring boot文件大小设置
spring.servlet.multipart.max-file-size=10MB
spring.servlet.multipart.max-request-size=10MB
#静态资源映射
spring.resources.static-locations=/static
########################################################
### SpringMail
########################################################
spring.mail.host=smtp.qq.com
spring.mail.username=867511789@qq.com
spring.mail.password=wangjv283203
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.properties.mail.smtp.starttls.required=true
########################################################
###FREEMARKER (FreeMarkerAutoConfiguration)
########################################################
spring.freemarker.allow-request-override=false
spring.freemarker.cache=true
spring.freemarker.check-template-location=true
spring.freemarker.charset=UTF-8
spring.freemarker.content-type=text/html
spring.freemarker.expose-request-attributes=false
spring.freemarker.expose-session-attributes=false
spring.freemarker.expose-spring-macro-helpers=false
#spring.freemarker.prefix=
#spring.freemarker.request-context-attribute=
#spring.freemarker.settings.*=
spring.freemarker.suffix=.ftl
spring.freemarker.template-loader-path=classpath:/templates/
#comma-separated list
#spring.freemarker.view-names= # whitelist of view names that can be resolved
########################################################
### 生产环境配置:开发环境dev,测试环境test,生产环境prod
########################################################
spring.profiles.active=dev
########################################################
### 全局变量
########################################################
sysName=后台管理系统
########################################################
### MyBatisPlus
########################################################
#MyBatis Mapper 所对应的 XML 文件位置
mybatis-plus.mapper-locations=classpath:/mapper/*Mapper.xml
#MyBaits 别名包扫描路径
mybatis-plus.typeAliasesPackage=org.jia.springboot.model
#主键类型 IdType.AUTO 数据库ID自增 IdType.INPUT 用户输入ID IdType.ID_WORKER 全局唯一ID,内容为空自动填充(默认配置) dType.UUID 全局唯一ID,内容为空自动填充
#0:"数据库ID自增", 1:"用户输入ID",2:"全局唯一ID (数字类型唯一ID)", 3:"全局唯一ID UUID";
mybatis-plus.global-config.db-config.id-type=1
#表名前缀
#mybatis-plus.global-config.db-config.table-prefix=tbl_
#字段验证策略 0:"忽略判断",1:"非 NULL 判断"),2:"非空判断"
mybatis-plus.global-config.field-strategy=0
#驼峰下划线转换(数据库中是下划线 ,java类中是下划线)
mybatis-plus.global-config.db-column-underline=true
#开发环境启用,部署环境关掉
#刷新mapper 调试神器
mybatis-plus.global-config.refresh-mapper=true
#数据库大写下划线转换
#mybatis-plus.global-config.capital-mode=true
#序列接口实现类配置
#mybatis-plus.global-config.key-generator=com.joey.*
#逻辑删除配置
#mybatis-plus.global-config.logic-delete-value=0
#mybatis-plus.global-config.logic-not-delete-value=1
#自定义填充策略接口实现
#mybatis-plus.global-config.meta-object-handler=com.joey.*
#自定义SQL注入器
#mybatis-plus.global-config.sql-injector=com.joey.*
mybatis-plus.configuration.map-underscore-to-camel-case=true
mybatis-plus.configuration.cache-enabled=false

81,094

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧