java - How to create spring bean that can be autowired using annotations? -


i've got small mvc web app controller configured using annotations.

the xml setup simple.

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemalocation="http://www.springframework.org/schema/beans                        http://www.springframework.org/schema/beans/spring-beans.xsd                        http://www.springframework.org/schema/context                        http://www.springframework.org/schema/context/spring-context.xsd">  <context:component-scan base-package="net.dynamic_tools.jsdependency" /> </beans> 

my controller looks like

@controller @requestmapping("/*") public class jsdependencycontroller {      @autowired     private scripttagsjsview scripttagsjsview; 

i'm getting error saying

no matching bean of type [net.dynamic_tools.jsdependency.view.scripttagsjsview] found dependency

i've tried adding component annotation scrittagsjsview

@component("scripttagsjsview") public class scripttagsjsview implements view { 

with no luck. i've tried adding configuration pojo , using @bean annotation

@configuration public class config {     @bean     public scripttagsjsview getscripttagsjsview() {         return new scripttagsjsview(); } 

i'm missing simple, can't see why isn't working. ideas?

i think might need <context:annotation-config/> in xml.


Comments