2015-10-06 91 views
0

我想在AppFuse(多模塊)中做一些基本的應用程序,並且我遇到了這個錯誤。我有一個DailyRecord實體,DailyRecordDao接口,DailyRecordDaoHibernate類,和DRManagerImpl類。AppFuse:mvn碼頭:運行找不到符號

有三種方法在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); 
} 

這裏是實現此接口

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 
    } 

} 

而這裏DailyRecordDaoHibernate是經理:

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()方法,everythig工作。我認爲這與依賴關係有關,但我真的不確定,因爲這對我來說真的很混亂。我已經在Web和核心目錄上嘗試過mvn clean compile,刪除這些目錄中的target文件夾,然後重新編譯它,但仍然沒有運氣。我會感謝任何幫助。

回答

0

好吧,所以我設法讓它工作。如果不更改什麼,我已經編寫了JUnit測試,如果dailyRecordDao.getDailyRecord()返回null基本測試。測試通過了,神奇的一切都變好了。我不確定我是否開心或者只是更困惑。

+1

你必須在你的核心項目上執行「mvn install」,以便你的web項目能夠完成它。 –

+0

啊,我想我只需要在項目的乞討中做到這一點,非常感謝你! –