Just thought about it: maybe @Resource(name = "personDao") instead of @Autowired
Von: René Günther [mailto:[EMAIL PROTECTED] Gesendet: Freitag, 28. Dezember 2007 06:59 An: [email protected] Betreff: AW: AW: [appfuse-user] Help with Spring 2.5 annotation You probably need another annotation then autowired then. Maybe ask at spring forum (www.springframework.org)? René Von: Le Anh Tuan [mailto:[EMAIL PROTECTED] Gesendet: Freitag, 28. Dezember 2007 03:37 An: [email protected] Betreff: Re: AW: [appfuse-user] Help with Spring 2.5 annotation Hi, What about Manager with GenericDAO? For example: ------------------------------------------- public class PersonManagerImpl extends GenericManagerImpl<Person, Long> implements PersonManager { GenericDao<Person, Long> personDao; public PersonManagerImpl(GenericDao<Person, Long> personDao) { super(personDao); this.personDao = personDao; } ------------------- Bean XML definition --------------- <bean id="personManager" class="com.myapp.service.impl.PersonManagerImpl"> <constructor-arg> <bean class="org.appfuse.dao.hibernate.GenericDaoHibernate" autowire="byType"> <constructor-arg value="com.myapp.model.Person" /> </bean> </constructor-arg> </bean> ----------------------------------------------- I tried with annotation @Service and @Autowired but it does not work. René Günther wrote: This works for me: @Service(“personManager”) public class PersonManagerImpl extends GenericManagerImpl<Person, Long> implements PersonManager { PersonDao personDao; @Autowired public PersonManagerImpl(PersonDao personDao) { super(personDao); this.personDao = personDao; } <beans xmlns= <http://www.springframework.org/schema/beans> "http://www.springframework.org/schema/beans" xmlns:xsi= <http://www.w3.org/2001/XMLSchema-instance> "http://www.w3.org/2001/XMLSchema-instance" xmlns:aop= <http://www.springframework.org/schema/aop> "http://www.springframework.org/schema/aop" xmlns:tx= <http://www.springframework.org/schema/tx> "http://www.springframework.org/schema/tx" xmlns:context= <http://www.springframework.org/schema/context> "http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd" default-lazy-init="true"> <context:component-scan base-package="com.company.project.service" /> Maybe it is just the name of the service that is missing? René Von: Le Anh Tuan [mailto:[EMAIL PROTECTED] Gesendet: Donnerstag, 27. Dezember 2007 05:48 An: [email protected] Betreff: Re: [appfuse-user] Help with Spring 2.5 annotation Hi Matt, I tried as you suggest, but the problem is Spring can not @Autowired property value, such as: <constructor-arg value="com.myapp.model.Person" />. I read through Spring 2.5 reference docs (Chapter 3 The IoC containner) but could not find example for this case. I know this is not Spring mailling list but any more suggestion should help! Thank you. Matt Raible wrote: You might try the following: <!-- Activates mapping of @Controller --> <context:component-scan base-package="org.appfuse.web"/> <!-- Activates @Autowired for Controllers --> <context:annotation-config/> I believe the first detects @Controller, @Service and @Repository. Matt On 12/26/07, Le Anh Tuan <mailto:[EMAIL PROTECTED]> <[EMAIL PROTECTED]> wrote: Hello, I have upgraded to AppFuse 2.0.1 with Spring 2.5 and found that Spring 2.5 annotation feature is great. I want to change this bean's XML definition below to spring annotation: <bean id="personManager" class="com.myapp.service.impl.PersonManagerImpl"> <constructor-arg> <bean class="org.appfuse.dao.hibernate.GenericDaoHibernate" autowire="byType"> <constructor-arg value="com.myapp.model.Person" /> </bean> </constructor-arg> </bean> I configured the class like this: @Service public class PersonManagerImpl extends GenericManagerImpl<Person, Long> implements PersonManager { PersonDao personDao; @Autowired public PersonManagerImpl(PersonDao personDao) { super(personDao); this.personDao = personDao; } But it does not work!. Hope any one help!. Thank you very much --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
