Latou_csdn 2018-08-03 09:02 采纳率: 0%
浏览 5217
已结题

SpringBoot在IDE可以正常运行,但是部署到Tomcat里就会启动失败

我打算使用spring-boot + mybits plus构建一个RESTful服务器,在Eclipse里可以正常运行。但是一旦打包放到Tomcat里就会出现如下错误(NoSuchBeanDefinition),个人推测是某些配置文件没写完整或者有错误,导致的实例注入失败。
不过我检查了很多遍,尝试了很多办法,依然还是会有这个问题。
请各路大神帮帮忙!!

目录结构:
java-xxx.xxx.xxx.xxx.dao
|-xxx.xxx.xxx.xxx.entity(也就是javaBean类)
|-xxx.xxx.xxx.xxx.service(业务逻辑接口)
|-xxx.xxx.xxx.xxx.service.impl(业务逻辑实现类)
|-xxx.xxx.xxx.xxx.controller
resource-mapper . xxx . xxx.xml

pom.xml版本信息:

mybatisplus.spring.boot.version-1.0.5
mybatis-plus-2.3
spring-boot-starter-parent-2.3

application.yml信息:
mybatis-plus部分如下

mapper-locations: classpath:mapper/**/*.xml
typeAliasesPackage: com.latou.power.modules.*.entity

Java版本-1.8.0
Tomcat版本-8.5

Tomcat报错如下:

ConfigServletWebServerApplicationContext :
Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'custUserController': Unsatisfied dependency expressed through field 'custUserService';

nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'custUserService': Unsatisfied dependency expressed through field 'baseMapper';

nested exception is org.springframework.beans.factory.NoSuchBeanDefinition Exception: No qualifying bean of type 'com.latou.power.modules.cus.dao.CustUserDao' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

  • 写回答

12条回答 默认 最新

  • 筱~破^ 2018-08-06 02:15
    关注
     <dependency>
     <groupId>org.springframework.boot</groupId>
     <artifactId>spring-boot-starter-tomcat</artifactId>
     <scope>provided</scope>
    </dependency>
    
     <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
             <exclusions>  
                    <exclusion>  
                        <groupId>org.springframework.boot</groupId>  
                        <artifactId>spring-boot-starter-tomcat</artifactId>  
                    </exclusion>  
                </exclusions> 
        </dependency>
    
    
    评论

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?