Tomcat启动时报One or more listeners failed to start的错误

在整合Spring与SpringMVC时,遇到Tomcat启动报错'One or more listeners failed to start'。通过查看log文件,发现在AccountServiceImpl.java中存在问题。注释掉相关代码后,错误解决,成功整合。具体原因可能是MyBatis配置不完整导致DAO层无法正常使用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

问题描述:

在使用spring整合springMVC时,出现了这样一个错误One or more listeners failed to start

11-Mar-2020 22:04:20.895 严重 [RMI TCP Connection(2)-127.0.0.1] org.apache.catalina.core.StandardContext.startInternal One or more listeners failed to start. Full details will be found in the appropriate container log file
11-Mar-2020 22:04:20.901 严重 [RMI TCP Connection(2)-127.0.0.1] org.apache.catalina.core.StandardContext.startInternal Context [/ssm_02_war_exploded] startup failed due to previous errors

错误信息提示我去看log文件,于是我查看log文件时,发现了错误的地方:

2020-03-11 21:59:25,033 770    [on(2)-127.0.0.1] ERROR work.web.context.ContextLoader  - Context initialization failed
org.springframework.beans.factory.UnsatisfiedDependencyException: 
Error creating bean with name 'accountService': Unsatisfied dependency expressed through field 'accountDao';
nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.dao.AccountDao' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

log文件说错误从accountService开始,于是查看相关类的代码:

相关的代码:

AccountServiceImpl.java中的相关代码:

@Service("accountService")
public class AccountServiceImpl implements AccountService {

    @Autowired
    private AccountDao accountDao;

    /**
     * 业务层调用Dao层实现查询账户信息
     * @return
     */
    public List<Account> findAll() {
        System.out.println("业务层:执行查询所有方法......确定是");
//        List<Account> accounts = accountDao.findAll();
        return null;
    }
解决:

于是我把private AccountDao accountDao;这行注释掉,就不报错了。spring也成功的可以整合springMVC了。至于具体原因,暂时不是很明确,猜测是mybatis没有配置,dao层就不让用。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值