Reputation: 4122
I am having trouble injecting a service into a custom tag I created:
@Configurable
public MyTag extends BodyTagSupport{
@Autowired
private MyService service;
@Override
public int doStartTag(){
......
service.callServiceMethod(); // service is null
....
}
.......
}
Is there a way to inject beans using @Configurable in Custom Tags? I do not want to use following approach to inject beans:
ServletContext sc = ((PageContext) getJspContext()).getServletContext();
ApplicationContext context =
WebApplicationContextUtils.getWebApplicationContext(sc);
Upvotes: 0
Views: 1668
Reputation: 49935
@Configurable requires Compile time or load time weaving using AspectJ to be enabled. It will not work with normal Spring AOP, can you please confirm your project uses AspectJ.
Upvotes: 2