小糊塗,基本彈簧MVC應用程序具有這樣的:彈簧基本的MVC範例應用程序,註釋掃描混亂
應用-config.xml中
<context:component-scan base-package="org.springframework.samples.mvc.basic" />
和MVC-config.xml中具有:
<!-- Configures the @Controller programming model -->
<mvc:annotation-driven />
你真的需要兩個嗎?
組件掃描,這是否意味着如果我沒有把正確的包路徑我的@Controller和@Service標記將沒有任何影響? 如果我需要多個包裝,我只需複製條目?
我試着只用MVC:註解驅動,但沒有工作,我不得不把com.example.web.controllers在組件掃描XML節點,使其工作。
只是出於好奇:背景:組件掃描包括AutowiredAnnotationBeanPostProcessor和CommonAnnotationBeanPostProcessor會,這意味着意味着兩個組件都會被自動檢測並連接在一起 - **無不在XML中提供任何bean配置元數據** – 2010-07-01 03:11:16
謝謝,我不想做br.com.app,因爲它將會掃描潛在更多的課程而不是所需的課程。很好的回答!順便說一句什麼是@Component和@Service之間的差異? – Blankman 2010-07-01 04:02:23
@Blankman無。 @Service也是一個@Component註釋。在這裏看到:http://static.springsource.org/spring/docs/2.5.6/api/org/springframework/stereotype/Service.html這僅僅是一個特殊的元數據,以**表示在服務層中的服務組件* *。 – 2010-07-01 04:10:39