I tried using the @Configurable annotation in the Spring petclinic example, but it's not working for me.
In application-context-jdbc.xml, I added these lines:
<context:annotation-config />
<context:spring-configured />
<context:load-time-weaver />
In petclinic-servlet.xml I added component scanning of the validation package, because my configurable class is in that package. So now my component-scan snippets are:
<!--Was already there -->
<context:component-scan base-package="org.springframework.samples.petclinic.web "/>
<!-- New -->
<context:component-scan base-package="org.springframework.samples.petclinic.val idation" />
(Notes: 1) For some reason 'validation' is formatted here so that there's a separation between the 'l' and the 'i', at least when viewed on my browser. That's not the case in the actual applicationContext. 2) I decided not to simply scan org.springframework.samples because that caused errors when the HibernateClinic expects a SessionFactory to be autowired, and I'm using the jdbc version of the petclinic for now.)
I attempted to make OwnerValidator configurable. Here's the relevant code:
@Configurable(dependencyCheck=true)
public class OwnerValidator {
private Clinic clinic;
@Autowired
public void setClinic(Clinic clinic){
System.out.println("Autowiring worked.");
this.clinic = clinic;
System.out.println("Value of clinic is " + clinic);
}
Finally, I ran Tomcat from Eclipse, adding -javaagent:C:\spring-agent.jar to the end of the jvm argument string.
Result: The Clinic was never autowired into the OwnerValidator.
Any suggestions would be appreciated.


Reply With Quote
="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop"