我有上述异常的问题请给出指导,这是我的代码:
//Calling Class
package com.company.product.wsai.qb.ws.endpoint;
//Imports
@Endpoint
public class SendRequestXMLEndpoint implements SendRequestXMLManagementService {
String strErrorMsg = "";
// xml logging
private static final String SEND_REQUEST_XML = "sendRequestXML";
private static final String SEND_REQUEST_XML_RESPONSE = "sendRequestXMLResponse";
@Autowired
com.intuit.developer.ObjectFactory wsObjectFactory;
@Autowired
com.intuit.quickbooks.ObjectFactory qbObjectFactory;
@Autowired
TestService testService;
@Autowired
HistoryServiceImpl historyService;
public static List<TaCategorySyncEntityDTO> travelAgentCategoryList ; //Match to customerType in QB
public static List<TravelAgentSyncEntityDTO> travelAgentList; //Match to customer in QB
public static List<VendorSyncEntityDTO> vendorList; //Match to vendor in QB
public static List<CurrencySyncEntityDTO> currencyList; //Match to currency in QB
public static List<ItemSyncEntityDTO> itemInventoryList; //Match to Item in QB
public void doTravelAgent(){
try{
//Methods
}catch (Exception e) {
e.printStackTrace();
}
}
public void doTravelAgentCategory(){
try{
//Methods
}catch (Exception e) {
e.printStackTrace();
}
}
public void doVendor(){
try{
//Methods
}catch (Exception e) {
e.printStackTrace();
}
}
public void doCurrency(){
try{
//Methods
}catch (Exception e) {
e.printStackTrace();
}
}
@PayloadRoot(localPart = "sendRequestXML", namespace = XmlConfig.QB_WC_NAMESPACE)
@ResponsePayload
public SendRequestXMLResponse sendRequestXMLCommon(@RequestPayload SendRequestXML sendRequestXML) {
doTravelAgentCategory();
doTravelAgent();
doVendor();
doCurrency();
String sessionTicket = sendRequestXML.getTicket();
String strCompanyFileName = sendRequestXML.getStrCompanyFileName();
// log request
XmlLogManager.logSendRequestXMLEnpoint(sendRequestXML, SEND_REQUEST_XML, sessionTicket);
SendRequestXMLResponse sendRequestXMLResponse = wsObjectFactory.createSendRequestXMLResponse();
sendRequestXMLResponse.setSendRequestXMLResult(getSentXMLResult());
// log response
XmlLogManager.logSendRequestXMLEnpoint(sendRequestXMLResponse, SEND_REQUEST_XML_RESPONSE, sessionTicket);
updateHistory();
return sendRequestXMLResponse;
}
private String getSentXMLResult() {
try{
//Generate XML for quickBook
} catch (JAXBException e) {
e.printStackTrace();
}
return stringWriter.toString();
}
public void updateHistory(){
History taHistory = new History();
Date dtReturn = StringToDate("19-06-2014");
System.out.println(dtReturn);
taHistory.setId(1L);
taHistory.setEntityEvent('C');
taHistory.setEntityType("TRAVELAGENT");
taHistory.setEntityName("TEST");
taHistory.setHotelCode("BBH");
taHistory.setRecordTransfered('1');
taHistory.setCreatedBy("TEST_USER");
taHistory.setCreatedDate(dtReturn);
taHistory.setVersion(1);
try{
historyService.saveHistory(taHistory);
}catch (Exception e) {
e.printStackTrace();
}
}
public static Date StringToDate(String strDate) {
Date dtReturn = null;
return dtReturn;
}
}
//DAO Implementation class
package com.company.product.wsai.qb.dao.historyDAO;
//imports
public class HistoryDAOImpl implements HistoryDAO {
private SessionFactory sessionFactory;
public SessionFactory getSessionFactory() {
return sessionFactory;
}
public void setSessionFactory(SessionFactory sessionFactory) {
this.sessionFactory = sessionFactory;
}
@Override
public void saveHistory(History history) {
sessionFactory.getCurrentSession().save(history);
}
}
//Service implementation
package com.company.product.wsai.qb.historyService;
//imports
public class HistoryServiceImpl实现HistoryService {
@Autowired
private HistoryDAO historyDAO;
public void saveHistory(History history) {
historyDAO.saveHistory(history);
}
}
//Config xml
//remove upper part
<context:component-scan base-package="com.jkcsworld.zhara.wsai.qb.historyService" />
<context:component-scan base-package=" com.jkcsworld.zhara.wsai.qb.dao.historyDAO" />
<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="configLocation">
<value>/resources/hibernate.cfg.xml</value>
</property>
</bean>
<bean id="historyDAO" class="com.jkcsworld.zhara.wsai.qb.dao.historyDAO.HistoryDAOImpl">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
</beans>
当我在调用类中包含自动装配时,它在屏幕截图中出现错误
答案 0 :(得分:0)
您的组件扫描也应该涵盖此软件包
package com.company.product.wsai.qb.ws.endpoint;
按如下方式编辑config.xml,只需一次组件扫描即可。
<context:component-scan base-package="com.jkcsworld.zhara.wsai.qb" />
<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="configLocation">
<value>/resources/hibernate.cfg.xml</value>
</property>
</bean>
<bean id="historyDAO" class="com.jkcsworld.zhara.wsai.qb.dao.historyDAO.HistoryDAOImpl">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
问题是找不到SendRequestXMLEndpoint.historyService
将您的服务标记为
package com.company.product.wsai.qb.historyService;
//imports
@Service // Mark it as service
public class HistoryServiceImpl implements HistoryService {
@Autowired
private HistoryDAO historyDAO;
public void saveHistory(History history) {
historyDAO.saveHistory(history);
}
}
答案 1 :(得分:0)
@Autowired
public void setSessionFactory(SessionFactory sessionFactory) {
this.sessionFactory = sessionFactory;
}
修改您的HistoryDAOImpl类以使用上述方法。它应该可以工作。