Spring SSM3 use the framework of the MVC 3.1 + Spring 3.1 + Mybatis3.1
first case :
Spring and Spring MVC integration time, SpringMVC of springmvc.xml configuration file scanning package, do not include the service notes, Spring of applicationContext. when package scanning configuration xml file, do not include annotations controller, as follows:
SPRINGMVC xml configuration:
first case :
Spring and Spring MVC integration time, SpringMVC of springmvc.xml configuration file scanning package, do not include the service notes, Spring of applicationContext. when package scanning configuration xml file, do not include annotations controller, as follows:
SPRINGMVC xml configuration:
<context:component-scan base-package="com.insigma">
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service"/>
</context:component-scan>
Spring MVC
configuration file at startup, contains components scan,
url
mapping and setting
freemarker
parameters, so that
spring
does not scan with
@Service
class annotations. Why should this set? Because
springmvc.xml
and
applicationContext.xml
not loaded at the same time, if not such a setting, then,
the Spring will bring all @Service class notes are scanned into the container, until the load applicationContext .xml time, because the container has been existence Service category, making cglib will not Service proxy, a direct result of that is
applicationContext configuration does not work in the business, when an exception occurs, the data can not be rolled back. These are the reason why.
Xml arranged in the same Spring follows:
Xml arranged in the same Spring follows:
<context:component-scan base-package="com.insigma">
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
Scan path package, with no scanning
@Controller
class annotated. Because these classes has been started with the container in
springmvc.xml
scanned it again in.
Completion of the above
note above points on OK.
Completion of the above
note above points on OK.
This article is reprinted. . . . . . . . . . .