org.springframework.beans.factory.UnsatisfiedDependencyException异常

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘OTAFirmwareMessageController’: Unsatisfied dependency expressed through field ‘otaFirmwareMessageService’; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘OTAFirmwareMessageServiceImpl’: Unsatisfied dependency expressed through field ‘otaFirmwareMapper’; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘otaFirmwareMapper’ defined in file [D:\ttttt\lorawan-ota\target\classes\cn\com\polycis\mapper\OtaFirmwareMapper.class]: Unsatisfied dependency expressed through bean property ‘sqlSessionFactory’; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘sqlSessionFactory’ defined in class path resource [com/baomidou/mybatisplus/spring/boot/starter/MybatisPlusAutoConfiguration.class]: Unsatisfied dependency expressed through method ‘sqlSessionFactory’ parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘dataSource’ defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Tomcat.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.tomcat.jdbc.pool.DataSource]: Factory method ‘dataSource’ threw exception; nested exception is java.lang.IllegalStateException: Cannot load driver class: com.mysql.jdbc.Driver
在整合mybatis-plus插件2.3版本的时候,pom文件有个

 <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>test</scope>
        </dependency>

与项目中的

<dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>

冲突了,scope域中,存在测试和运行状态两个相互冲突的状态,导致出错,解决办法是,既然测试和运行都需要,就把scope域删除就行了

猜你喜欢

转载自blog.csdn.net/reee112/article/details/84581132