当前位置: 首页 > 知识库问答 >
问题:

DAOS的hybris出错-服务

步嘉德
2023-03-14

这是错误:

WARN[localhost-startStop-1][CloseAwareApplicationContext]上下文初始化过程中遇到异常-取消刷新尝试:org.springFramework.beans.factory.BeanCreationException:创建类路径资源[trainingCore-spring.xml]中定义的名为“Total CustomersDAO”的bean时出错:设置属性值时出错;嵌套异常为org.springframework.beans.NotWritablePropertyException:bean类[de.hybris.training.core.dao.impl.TotalCustomersDaoImpl]的属性“model service”无效:bean属性“model service”不可写或具有无效的setter方法。setter的参数类型是否与getter的返回类型匹配?WARN[localhost-startStop-1][CloseAwareApplicationContext]上下文初始化过程中遇到异常-取消刷新尝试:org.springFramework.beans.factory.BeanCreationException:创建类路径资源[trainingCore-spring.xml]中定义的名为“Total CustomersDAO”的bean时出错:设置属性值时出错;嵌套异常为org.springframework.beans.NotWritablePropertyException:bean类[de.hybris.training.core.dao.impl.TotalCustomersDaoImpl]的属性“model service”无效:bean属性“model service”不可写或具有无效的setter方法。setter的参数类型是否与getter的返回类型匹配?错误[localhost-startStop-1][HybrisContextFactory]初始化全局应用程序上下文时出错!org.springframework.beans.factory.beanCreationException:创建类路径资源[trainingcore-spring.xml]中定义的名为“Total CustomersDAO”的bean时出错:设置属性值时出错;嵌套异常为org.springframework.beans.NotWritablePropertyException:bean类[de.hybris.training.core.dao.impl.TotalCustomersDaoImpl]的属性“model service”无效:bean属性“model service”不可写或具有无效的setter方法。setter的参数类型是否与getter的返回类型匹配?

trainingCore.spring.xml

<!-- Total Customer service dao facade-->

<alias alias="totalCustomersDao" name="totalCustomersDao"/>
<bean id="totalCustomersDao"
      class="de.hybris.training.core.dao.impl.TotalCustomersDaoImpl"
      parent="abstractItemDao" >
    <property name="flexibleSearchService" ref="flexibleSearchService"/>
</bean>

<bean id="totalCustomerService"
      class=" de.hybris.training.core.impl.TotalCustomerServiceImpl" >
    <property name="totalCustomersDao" ref="totalCustomersDao"/>
</bean>

<bean id="totalCustomerFacade" class="de.hybris.training.core.facade.impl.TotalCustomerFacadeImpl">
    <property name="totalCustomerService" ref="totalCustomerService"/>
</bean>

TotalCustomersDAOIMPL

public class TotalCustomersDaoImpl implements TotalCustomersDao { private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(UsersFindJob.class);

    private static final String query =
            "SELECT *" +
            "FROM {" + CustomerModel._TYPECODE + "}"+
            "WHERE p_name  LIKE "
                    + "'%" + CustomerModel.NAME+"+%'";


    private DefaultFlexibleSearchService flexibleSearchService;

    public List<CustomerModel> findAllCustomersFromDao(String name) {

        LOG.info("***********************************");
        LOG.info("***********************************");
        LOG.info("*************************findAllCustomersFromDao**********");
        LOG.info("***********************************");
        LOG.info("***********************************");

        final Map<String, Object> params = new HashMap<String, Object>();
        params.put(CustomerModel.NAME, name);

        FlexibleSearchQuery fQuery = new FlexibleSearchQuery(query);
        if (params != null) {
            fQuery.addQueryParameters(params);
        }

        final SearchResult<CustomerModel> result = flexibleSearchService.search(fQuery);
        return result.getResult();
    }


    public void setFlexibleSearchService(DefaultFlexibleSearchService flexibleSearchService) {
        this.flexibleSearchService = flexibleSearchService;
    }

    public DefaultFlexibleSearchService getFlexibleSearchService() {
        return flexibleSearchService;
    }

}

TotalCustomerFacadeImpl

public class TotalCustomerFacadeImpl implements TotalCustomerFacade {

//TODO autowired or resoucre not work
    private TotalCustomerService totalCustomerService; private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(UsersFindJob.class);

    public TotalCustomerService getTotalCustomerService() {
        return totalCustomerService;
    }

    public void setTotalCustomerService(TotalCustomerService totalCustomerService) {
        this.totalCustomerService = totalCustomerService;
    }


    @Override
    public List<String> findCustomerContainingName(String firstName) {



        List<CustomerModel> customerModels;
        List<String> customerFirstNames = new ArrayList<>();
        LOG.info("***********************************");
        LOG.info("***********************************");
        LOG.info("*************************findCustomerContainingName**********");
        LOG.info("***********************************");
        LOG.info("***********************************");
        customerModels = totalCustomerService.getAllCustomersNames(firstName);
        LOG.info("***********************************");
        LOG.info("***********************************");
        LOG.info("*************************2findCustomerContainingName**********");
        LOG.info("***********************************");
        LOG.info("***********************************");


        for (int i = 0; i < customerModels.size(); i++) {


            final String fName = splitName(customerModels.get(i).getName())[0];


                customerFirstNames.add(fName);//adding first name

        }
        return customerFirstNames;


    }

TotalCustomerServiceImpl

public class TotalCustomerServiceImpl implements TotalCustomerService {
    private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(UsersFindJob.class);

    private TotalCustomersDao totalCustomersDao;

    public TotalCustomersDao getTotalCustomersDao() {
        return totalCustomersDao;
    }

    public void setTotalCustomersDao(TotalCustomersDao totalCustomersDao) {
        this.totalCustomersDao = totalCustomersDao;
    }

错误表示bean属性“model service”不可写或具有无效的setter方法。

我没有使用modelservice

对于Dao和服务类,我有XML和Java中的真实名称。在IntelliJ idea中当我点击XML时,我可以到我期望去的地方去Java类。

共有1个答案

长孙弘盛
2023-03-14

问题是,您在XML中为TotalCustomersDAO声明了parent=“AbstractItemDAO”,另一方面您还没有实现AbstractItemDAO类。

换句话说,您的类没有XML bean定义中实际定义的任何modelService属性,这导致modelService的NotWritablePropertyException

如果您根本不想使用AbstractItemDao类中的任何内容,则可以从TotalCustomersDAO声明中删除parent=“AbstractItemDao”

<alias alias="totalCustomersDao" name="totalCustomersDao"/>
<bean id="totalCustomersDao"
      class="de.hybris.training.core.dao.impl.TotalCustomersDaoImpl">
    <property name="flexibleSearchService" ref="flexibleSearchService"/>
</bean>

扩展TotalCustomersDaoImpl中的AbstractEmdao

public class TotalCustomersDaoImpl extends AbstractItemDao implements TotalCustomersDao
 类似资料:
  • 请帮我做这个,谢谢。

  • 我正在尝试从后台同步YaaS配置。我有400个错误 ` ` 以下是我的数据中心配置: ` ` 你有什么想法吗?

  • 我写了下面的代码- 在中 workflow.py- 和 但我犯了一个错误- FileWatcherSystemd.Service-FileChangeService loaded:loaded(/lib/systemd/system/FileWatcherSystemd.Service;enabled;vendor Preset:enabled)Active:inactive(dead)(结果:e

  • SAP商务1905 我有一个节点应用程序,我想与我的Hybris集成。我已经创建了一个自定义的addon,并将我的节点应用程序文件放在addon扩展中。现在我想在Hybris服务器start上运行下面的命令。 通过将npm命令放在myextension_compileuisrc_executor buildcallback下,我可以在ant构建上启动节点服务器。 但我的目标是只在MyExtensi

  • 问题内容: 我刚刚完成了重新安装操作系统的工作,并且像往常一样安装和测试了我使用的标准工具,现在当我尝试从eclipse启动Jboss 5时,出现了前所未有的错误: 以前有没有人遇到过类似的问题?到目前为止我从未遇到过 问题答案: 看起来像是JRE和OS版本的某些特定组合发生的错误(请参阅https://jira.jboss.org/jira/browse/JBAS-6981)。基本上,JBoss

  • 错误:传输错误202:绑定失败:地址已在使用错误:JDWP传输dt_socket初始化失败,TRANSPORT_INIT(510)JDWP退出错误AGENT_ERROR_TRANSPORT_INIT(197):未初始化传输[debuginit.c:750]本机方法中的致命错误:JDWP未初始化传输,jvmtierror=AGENT_ERROR_TRANSPORT_INIT(197) 知道吗?