2015-01-02 2 views
0

스프링 종속성 삽입을 사용하여 웹 응용 프로그램에 일부 객체를 주입하려고합니다.응용 프로그램 컨텍스트 xml 파일의 이름 지정 속성

@Autowired 
private IEtudiantDao etudiantDao; 

그리고 EtudiantAction 클래스에서 내가 가진 : EtudiantServiceImpl 클래스에서

내가 가진

@Autowired 
private EtudiantServiceImpl etudiantService; 
@Autowired 
public Etudiant etudiant; 

그리고 내 응용 프로그램 컨텍스트 XML 파일에

나는이 있습니다

<bean name="etudiantAction" class="tp.ihm.gestionEtudiants.web.EtudiantAction" scope="prototype"> 
     <property name="etudiantService"> 
      <ref bean="etudiantService"/> 
     </property> 
     <property name="etudiant" class="tp.ihm.gestionEtudiants.domain.Etudiant"> 
     </property> 
    </bean> 

    <bean id="etudiantService" class="tp.ihm.gestionEtudiants.service.EtudiantServiceImpl"> 
     <property name="etudiantDao" class="tp.ihm.gestionEtudiant.dao.EtudiantDaoImpl"> 
     </property> 
    </bean> 

그러나 xml 파일에 오류가 표시됩니다 :

Attribute : name 
The name of the property, following JavaBean naming conventions. 

Data Type : string 

: <property name="etudiantService">name="etudiant"<property name="etudiantDao".

어떻게 해결할 수 있습니까?

+0

'클래스에서 전체를 제거 할 수 있습니다 지금

@Service

로 그냥 주석, EtudiantServiceImpl에 대한 @Controller로

@Controller class EtudiantAction{ ... Same as your code } 

같은 일을 EtudiantAction 주석 '. 'ref' 또는'value'를 지정할 수 있습니다. 또한 구체적인 구현이 아니라 클래스에서 EtudiantDao와 EtudiantService 인터페이스를 사용해야한다. –

답변

0

우선 "AutoWired"로 정의하면 XML 파일에서 정의 할 필요가 없습니다. 당신이 컨텍스트 XML

은`property` 태그는 속성이없는
관련 문제