AppFuse:mvn jetty:运行找不到符号

时间:2015-10-06 16:20:55

标签: java maven appfuse

我试图在AppFuse(多模块)中做一些基本的应用程序,并且我遇到了这个错误。我有一个DailyRecord实体,DailyRecordDao接口,DailyRecordDaoHibernate类和DRManagerImpl类。

DailyRecordDao中有三种方法:

package com.diary.dao;

import java.sql.Date;
import java.util.List;

import org.appfuse.dao.GenericDao;

import com.diary.model.DailyRecord;

public interface DailyRecordDao extends GenericDao<DailyRecord, Long> {

    public List<DailyRecord> getDailyRecordsFrom(Date date, Long memberID);

    public DailyRecord getTodayDailyRecord(Long memberID);

    public DailyRecord getDailyRecord(Long memberID);
}

这是实现此接口的DailyRecordDaoHibernate

package com.diary.dao;

import java.sql.Date;
import java.util.Calendar;
import java.util.List;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.appfuse.dao.hibernate.GenericDaoHibernate;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.diary.model.DailyRecord;

@Repository("dailyRecordDao")
public class DailyRecordDaoHibernate extends GenericDaoHibernate<DailyRecord, Long>
        implements DailyRecordDao {

    public DailyRecordDaoHibernate() {
        super(DailyRecord.class);
    }

    @Override
    public List<DailyRecord> getDailyRecordsFrom(Date date, Long memberID) {
        // TODO Auto-generated method stub
        return null;   //this isn't importat right now
    }

    @Override
    public DailyRecord getTodayDailyRecord(Long memberID) {

        return null;   //again not important, but this method works well when called in DRManagerImpl
    }

    @Override
    public DailyRecord getDailyRecord(Long memberID) {
        // TODO Auto-generated method stub
        return null;    //this method causes the problem
    }

}

这是经理:

package com.diary.service;

import java.sql.Date;
import java.util.List;

import org.appfuse.service.impl.GenericManagerImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.diary.dao.DailyRecordDao;
import com.diary.model.DailyRecord;


@Service("drm")
public class DRManagerImpl extends GenericManagerImpl<DailyRecord, Long> implements
        DRManager {

    private DailyRecordDao drDao;

    @Autowired
    public DRManagerImpl(DailyRecordDao dailyRecordDao) {
        this.drDao = dailyRecordDao;
    }

    @Override
    public List<DailyRecord> getAll() {
        // TODO Auto-generated method stub
        return drDao.getAll();
    }

    @Override
    public List<DailyRecord> getDailyRecordsFrom(Date date, Long memberID) {
        // TODO Auto-generated method stub
        return drDao.getDailyRecordsFrom(date, memberID);
    }

    @Override
    public DailyRecord getTodayDailyRecord(Long memberID) {
        // TODO Auto-generated method stub
//      return drDao.getTodayDailyRecord(memberID);   this works
        return drDao.getDailyRecord(memberID);       //this will cause the error
    }

}

当我尝试使用mvn jetty:run运行应用程序时出现此错误

[ERROR] COMPILATION ERROR :
[INFO] --------------------------------------
[ERROR] .../web/src/main/java/com/diary/service/DRManagerImpl.java[46,29] cannot find symbol
  symbol:    method getDailyRecord(java.lang.Long)
  location:  variable drDao of type com.diary.dao.DailyRecordDao

但是如果取消注释管理器中的getTodayDailyRecord()并对getDailyRecord()方法发表评论,那么每个方法都可行。我认为它与家属有关,但我真的不确定,因为这对我来说真的很混乱。我已经在Web和核心目录上尝试了mvn clean compile,删除了这些目录中的target文件夹,然后再次重新编译,但仍然没有运气。我将不胜感激。

1 个答案:

答案 0 :(得分:0)

好的,所以我设法让它运转起来。在不更改任何的情况下,我编写了JUnit测试,基本测试dailyRecordDao.getDailyRecord()是否返回null。测试通过,一切都很神奇。我不确定自己是开心还是更加困惑。