我想在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
文件夾,然後重新編譯它,但仍然沒有運氣。我會感謝任何幫助。
你必須在你的核心項目上執行「mvn install」,以便你的web項目能夠完成它。 –
啊,我想我只需要在項目的乞討中做到這一點,非常感謝你! –