依赖注入在grails 2.3.7版本中不起作用

时间:2019-05-27 10:56:16

标签: grails-2.0

创建了grails 2.3.7 rest应用程序,其中控制器中未发生服务的自动装配,下面是controller和service的代码,都在grails-app文件夹下,下面是目录结构的链接。

enter image description here

        package com.peelworks

            class OneSFController extends grails.rest.RestfulController{

                OneSFService oneSFService;
                static responseFormats = ['json'];
                def List<Salesman> getSalesMan(){

                   return oneSFService.getSalesMan(); // this is where 
    the oneSFService is null
                }

            }

         - Service code

    package com.peelworks
    import com.peelworks.dao.OneSFDAO
    class OneSFService {

         OneSFDAO oneSFDAO;

        List<Salesman> getSalesMan(){
            return oneSFDAO.getSalesMan(); // here the onseSFDAO is also null
        }
    }

0 个答案:

没有答案