Spring @Autowired not working

后端 未结 7 1952
再見小時候
再見小時候 2021-02-08 12:35

I have some problems wth autowire annotation. My app looks like this:

Here is controller:

@Controller
public class MyController {
    @Autowired
    @Qua         


        
7条回答
  •  一向
    一向 (楼主)
    2021-02-08 12:45

    You should include this section of XML code in spring-config.xml :

    
    

    but you should know the difference between vs as most people are suggesting these two :

    1) First big difference between both tags is that is used to activate applied annotations in already registered beans in application context. Note that it simply does not matter whether bean was registered by which mechanism e.g. using or it was defined in application-context.xml file itself.

    2) Second difference is driven from first difference itself. It does register the beans in context + it also scans the annotations inside beans and activate them. So ; does what does, but additionally it scan the packages and register the beans in application context.

提交回复
热议问题