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

问题描述:

在使用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 accounts = accountDao.findAll();
        return null;
    }

解决:

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

你可能感兴趣的:(Java,Bug)