gpt4 book ai didi

java - mybatis + spring boot 1.4.2 : MybatisAutoConfiguration$$EnhancerBySpringCGLIB Constructor threw exception NoUniqueBeanDefinitionException

转载 作者:行者123 更新时间:2023-12-02 11:20:18 29 4
gpt4 key购买 nike

我在尝试将 spring boot 1.4.2 应用程序部署到 tomcat 7 时收到此错误:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'applicationServiceImpl': Unsatisfied dependency expressed through field 'applicationDao'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'applicationDao' defined in file [E:\sources\apache-tomcat-7.0.86\webapps\OnlineChannelBackend-0.0.1-SNAPSHOT\WEB-INF\classes\com\pack\dao\ApplicationDao.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration': Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration$$EnhancerBySpringCGLIB$$f214bdd7]: Constructor threw exception; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'java.lang.Object' available: expected single matching bean but found 4: &applicationDao,systemEnvironment,contextParameters,contextAttributes

我的相关构建gradle:

sourceCompatibility = 1.6 //java6
targetCompatibility = 1.6

dependencies {
compile('org.springframework.boot:spring-boot-legacy:1.1.0.RELEASE')
compile('org.springframework.boot:spring-boot-starter-web:1.4.2.RELEASE')
compile('org.mybatis.spring.boot:mybatis-spring-boot-starter:1.3.2')
compile('com.oracle:ojdbc6:11.1.0.7.0') //java6
providedRuntime('org.apache.tomcat:tomcat-juli:7.0.59') // java6
compile group: 'org.apache.tomcat', name: 'tomcat-jdbc', version: '7.0.59'

并且在 com.pack.dao 中,我有 3 个用 @Mapper 注释的映射器接口(interface)以及资源中相应文件夹中的相应 xml 文件...该应用程序在 Spring Boot 2 中运行良好,但是一旦我开始将其更改为 Spring Boot 1.4.2 我无法让它工作

最佳答案

因为它在以前的 spring 版本中工作,我相信你有配置文件,所以你可能需要为我的 batis 排除 spring 自动配置器。

@SpringBootApplication
@EnableAutoConfiguration(exclude = {MybatisAutoConfiguration.class})

关于java - mybatis + spring boot 1.4.2 : MybatisAutoConfiguration$$EnhancerBySpringCGLIB Constructor threw exception NoUniqueBeanDefinitionException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49970370/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com