简体   繁体   English

无法将DWR与Spring合并

[英]Not able to merge DWR with Spring

Using spring 4.2.0, Dwr 3. Using annotations to create all spring controllers, service and daos. 使用spring 4.2.0,Dwr 3.使用注释创建所有弹簧控制器,服务和daos。 Working fine till it's in spring only environment. 工作正常,直到它只在春天的环境。 Trying to add DWR as seperate spring controller service object is not injecting into that DWR controller. 尝试将DWR添加为单独的弹簧控制器服务对象不会注入该DWR控制器。 Getting below error with NullPointerException 使用NullPointerException获取以下错误

found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

Below is the code snippet. 以下是代码段。 Dwr Controller is Dwr控制器是

@Controller
@RemoteProxy(name = "dwrDemo")
public class DwrDemoController {
@Autowired
private BrandNameService brandNameService;


public void setBrandNameService(BrandNameService brandNameService) {
    this.brandNameService = brandNameService;
}


@RemoteMethod
public List<String> getEmployeeDetails(int id) {
   return brandNameService.getEmployeeDetails(id);
}
:
}

Service class is like 服务类就像

@Service("brandNameService")
@Transactional
public class BrandNameServiceImpl implements BrandNameService{
  public List<String> getEmployeeDetails(int id) {
     return brandNameDAO.getEmployeeDetails(id);
  }
:
}

If I define the DWR controller in xml and removing all annotations in DWR Controller, server it getting up without initializing service object (here while calling dwr getting NullPointerException) Below is XML 如果我在xml中定义DWR控制器并删除DWR Controller中的所有注释,服务器在没有初始化服务对象的情况下启动(这里调用dwr获取NullPointerException)下面是XML

<beans:bean id="dwrDemoController"
    class="com.classified.dwr.controller.DwrDemoController">
    <!-- <beans:property name="brandNameService" ref="brandNameService"/> -->
    <dwr:remote javascript="dwrService">
        <dwr:include method="getEmployeeDetails" />
    </dwr:remote>
</beans:bean>

If I uncomment brandNameService, tomcat is not getting up, getting above exception/error while up 如果我取消注释brandNameService,则tomcat没有起来,在启动时遇到异常/错误

当我在applicationContext.xml中定义所有bean而不是myapp-servlet.xml时,它工作正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM