在基本服务上找不到符号

cannot find symbol on a basic service

我在添加新方法时遗漏了一些东西,但我不知道是什么??它在 userDAO.countUsers 行中生成找不到符号编译错误:

@Autowired
private UserDAO userDAO;

    @Async
private Future<Long> searchCount(MultiValueMap<String, String> parameters) throws DaoException {


   userDAO.countUsers("bla bla");


    return new AsyncResult<Long>(Long.getLong("1")); // temp code
}

这是服务界面:

public interface UserDAO {

long countUsers(String bloblo) throws DaoException;

下面是实现:

    @Service("userDAO")
    @SuppressWarnings("unchecked")
    @Transactional(readOnly = true, timeout = Constants.TRANSACTION_TIMEOUT, propagation = Propagation.SUPPORTS)
    public class UserDaoImpl implements UserDAO {

@PersistenceContext
private EntityManager em;

   @Override
    public long countUsers(String bloblo) throws DaoException {
        // Build request
        final QueryCriteria qc = new QueryCriteria(bloblo);

        final StringBuilder request = prepareQuery(qc);
        request.replace(7, 21, "count(distinct user)");
        final Query query = em.createQuery(request.toString());

        // Build parameters
        addParameters(query, qc);

        // Execute
        try {
            return (Long) query.getSingleResult();
        } catch (final RuntimeException e) {
            LOG.error(e.getMessage(), e);
            throw new DaoException(e);
        }
    }

帮助非常感谢!

可能是你没有在行

中声明变量em
em.createQuery(request.toString());

确保您确实从 userDAO.countUsers() 调用(LanguageCode、UserType、UserRightOrder)中导入了 类。 也许你应该粘贴你的错误信息?

这是我的 maven 版本 (3.0.5) 与 JDK1.7 有问题。我升级到 3.3.x 版本,现在可以使用了。

感谢:

maven "cannot find symbol" message unhelpful