2016-05-28 9 views
0

私はspring mvcプロジェクトに新しいコントローラを追加し、以下のようにすべての注釈を追加しました...しかし、 「ここ新しいコントローラが作成された後、Spring MVC、Hibernateで「Autowired依存関係の注入が失敗しました」というメッセージが表示される

...私は問題を把握するために混乱しています... 404例外を取得し、コンソールに、私は以下のように例外を取得していますmは私のコントローラである:

@Controller 
@RequestMapping("/escProjectProgStatusController") 
public class ESCProjectProgStatusController { 
    @Autowired 
    ESCProjectProgStatusService escProjectProgStatusService; 
@RequestMapping(value = "/fetchUnitNameDropDown") 
    public @ResponseBody String fetchUnitNameDropDown(HttpServletRequest request){ 
     String strUnitNames = ""; 
     String strProjectId = request.getParameter("projectId")==null?"":request.getParameter("projectId"); 
     try { 
      strUnitNames = escProjectProgStatusService.fetchUnitNameFromProjectId(strProjectId); 
     } catch (Exception e) { 
      //logger.error(e); 
      throw e; 
     } 
     return strUnitNames.toString(); 
    } 
} 

サービスのImpl:

@Service("escProjectProgStatusServices") 
@Transactional 
public class ESCProjectProgStatusServiceImpl implements ESCProjectProgStatusService { 

    @Autowired 
    ESCProjectProgStatusDao escProjectProgStatusDao; 
@Override 
    public String fetchUnitNameFromProjectId(String strProjectId){ 
     JSONArray jsonArr = new JSONArray(); 
     JSONObject jsonObj = null; 
     List<ProjectUnit> listProjectUnit = null; 
     try{ 
      listProjectUnit = (List<ProjectUnit>)escProjectProgStatusDao.fetchUnitNameFromProjectId(strProjectId); 
      if(listProjectUnit!=null){ 
       for(ProjectUnit projectUnit :listProjectUnit){ 
        jsonObj = new JSONObject(); 
        jsonObj.put("unitType", projectUnit.getUnitType()); 
        jsonObj.put("unitName", projectUnit.getUnitName()); 
        jsonArr.add(jsonObj); 
       } 
      } 
     }catch(Exception e){ 
      //logger.error(e); 
     } 
     return jsonArr.toString(); 
    } 
} 

ダオのImpl:

@Repository("escProjectProgStatusDao") 
public class ESCProjectProgStatusDaoImpl implements ESCProjectProgStatusDao { 
    @Autowired 
    private SessionFactory sessionFactory; 
@Override 
    public List<ProjectUnit> fetchUnitNameFromProjectId(String strProjectId){ 
     List<ProjectUnit> listProjectUnit = null; 
     try { 
      Session session = sessionFactory.getCurrentSession(); 
      Criteria criteria = session.createCriteria(ProjectUnit.class); 
      criteria.add(Restrictions.eq("merchantProductID", strProjectId)); 
      listProjectUnit=criteria.list(); 
     }catch(Exception e){ 
      //logger.error(e); 
     } 
     return listProjectUnit; 
    } 
} 

例外とスタックトレース:

SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener 
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ESCProjectProgStatusController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.interland.b2b.service.ESCProjectProgStatusService com.interland.b2b.controller.ESCProjectProgStatusController.escProjectProgStatusService; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert value of type 'java.lang.String' to required type 'com.interland.b2b.service.ESCProjectProgStatusService'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [com.interland.b2b.service.ESCProjectProgStatusService]: no matching editors or conversion strategy found 
     at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1208) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) 
     at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303) 
     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) 
     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299) 
     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) 
     at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755) 
     at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:759) 
     at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480) 
     at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:434) 
     at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306) 
     at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106) 
     at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4973) 
     at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5467) 
     at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) 
     at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559) 
     at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549) 
     at java.util.concurrent.FutureTask.run(Unknown Source) 
     at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) 
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) 
     at java.lang.Thread.run(Unknown Source) 
    Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.interland.b2b.service.ESCProjectProgStatusService com.interland.b2b.controller.ESCProjectProgStatusController.escProjectProgStatusService; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert value of type 'java.lang.String' to required type 'com.interland.b2b.service.ESCProjectProgStatusService'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [com.interland.b2b.service.ESCProjectProgStatusService]: no matching editors or conversion strategy found 
     at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:561) 
     at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) 
     at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331) 
     ... 22 more 
    Caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert value of type 'java.lang.String' to required type 'com.interland.b2b.service.ESCProjectProgStatusService'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [com.interland.b2b.service.ESCProjectProgStatusService]: no matching editors or conversion strategy found 
     at org.springframework.beans.TypeConverterSupport.doConvert(TypeConverterSupport.java:74) 
     at org.springframework.beans.TypeConverterSupport.convertIfNecessary(TypeConverterSupport.java:54) 
     at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:961) 
     at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:942) 
     at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:533) 
     ... 24 more 
    Caused by: java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [com.interland.b2b.service.ESCProjectProgStatusService]: no matching editors or conversion strategy found 
     at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:287) 
     at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:124) 
     at org.springframework.beans.TypeConverterSupport.doConvert(TypeConverterSupport.java:61) 
     ... 28 more 

誰もがこのproblem..Manyの事前のおかげを取り除くために私を助けてください....

答えて

0

ESCProjectProgStatusServiceImplクラスの文字列パラメータ@Service注釈を削除します。

前:

@Service("escProjectProgStatusServices") 

後:私は、String @Serviceのパラメータが、それでも同じ問題を削除した:

@Service 
+0

mehdi_javan – Joy

関連する問題