我把dao類,service類都寫好了,然后測試的時候總是報空,不知道是不是哪里出錯了
1 回答

慕容森
TA貢獻1853條經驗 獲得超18個贊
寫main測試肯定是不行的,因為你在web環境中,一般serviceImpl中的dao之類的數據庫連接都由容器啟動的時候創建好了,不會報錯。但是你在main中,沒有這個環境啊??梢赃@么寫:
ApplicationContext ctx = new FileSystemXmlApplicationContext("WebContent/WEB-INF/spring/*.xml"); //創建容器類上下文
CfpanmouncementServiceImpl cfpanmouncementService= ctx.getBean("xxxxx");
List<xxxEntity> list = cfpanmouncementService.getReportListBy("xxxx");
添加回答
舉報
0/150
提交
取消