无法调试测试无法加载ApplicationContext

时间:2017-11-20 17:27:02

标签: debugging spring-boot gradle jhipster

我用Jhipster 4.10.2创建了一个新项目,我使用JDL_Studio创建了实体,并且我已经关注了example to add additional info to the user

在某些时候我得到一个错误,我想调试应用程序,所以为此我尝试调试Jhipster在java [test] / web / rest中生成的测试,但是当我运行在调试模式下,我得到以下异常:

java.lang.IllegalStateException: Failed to load ApplicationContext

...

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'categoriaServiceImpl' defined in file [/Users/robertofernandez/Documents/myVoto_project/out/production/classes/com/mysmartcity/myvoto/service/impl/CategoriaServiceImpl.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.mysmartcity.myvoto.service.mapper.CategoriaMapper' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}

当我运行./gradlew并且在我运行后尝试再次调试时,我得到以下额外原因添加到之前:

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.mysmartcity.myvoto.service.mapper.CategoriaMapper' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}

如何解决此问题才能进行调试?

package com.mysmartcity.myvoto.service.impl;

import com.mysmartcity.myvoto.service.CategoriaService;
import com.mysmartcity.myvoto.domain.Categoria;
import com.mysmartcity.myvoto.repository.CategoriaRepository;
import com.mysmartcity.myvoto.service.dto.CategoriaDTO;
import com.mysmartcity.myvoto.service.mapper.CategoriaMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * Service Implementation for managing Categoria.
 */
@Service
@Transactional
public class CategoriaServiceImpl implements CategoriaService{

    private final Logger log = LoggerFactory.getLogger(CategoriaServiceImpl.class);

    private final CategoriaRepository categoriaRepository;

    private final CategoriaMapper categoriaMapper;

    public CategoriaServiceImpl(CategoriaRepository categoriaRepository, CategoriaMapper categoriaMapper) {
        this.categoriaRepository = categoriaRepository;
        this.categoriaMapper = categoriaMapper;
    }

    /**
     * Save a categoria.
     *
     * @param categoriaDTO the entity to save
     * @return the persisted entity
     */
    @Override
    public CategoriaDTO save(CategoriaDTO categoriaDTO) {
        log.debug("Request to save Categoria : {}", categoriaDTO);
        Categoria categoria = categoriaMapper.toEntity(categoriaDTO);
        categoria = categoriaRepository.save(categoria);
        return categoriaMapper.toDto(categoria);
    }

    /**
     *  Get all the categorias.
     *
     *  @return the list of entities
     */
    @Override
    @Transactional(readOnly = true)
    public List<CategoriaDTO> findAll() {
        log.debug("Request to get all Categorias");
        return categoriaRepository.findAll().stream()
            .map(categoriaMapper::toDto)
            .collect(Collectors.toCollection(LinkedList::new));
    }

    /**
     *  Get one categoria by id.
     *
     *  @param id the id of the entity
     *  @return the entity
     */
    @Override
    @Transactional(readOnly = true)
    public CategoriaDTO findOne(Long id) {
        log.debug("Request to get Categoria : {}", id);
        Categoria categoria = categoriaRepository.findOne(id);
        return categoriaMapper.toDto(categoria);
    }

    /**
     *  Delete the  categoria by id.
     *
     *  @param id the id of the entity
     */
    @Override
    public void delete(Long id) {
        log.debug("Request to delete Categoria : {}", id);
        categoriaRepository.delete(id);
    }
}

提前致谢并感谢您的帮助。

0 个答案:

没有答案