Spring的XML配置标签整理

加载XML

Spring中加载xml配置文件的六种方式:https://blog.csdn.net/qq_20662113/article/details/77103162

组件扫描

<context:component-scan base-package="包路径"></context:component-scan>  

xml中配置了这个标签后,spring会自动在base-package这个指定的路径下面扫描带有@Component @Controller@Service等这些注解的类,注册为bean .
具体查看 : https://blog.csdn.net/chunqiuwei/article/details/16115135

静态资源处理

<mvc:default-servlet-handler/>

使用RESTFUL风格的时候,由于URL都不带后缀,在访问静态资源的时候Spring mvc把它当作请求处理就会出错,加了这个标签后Spring mvc才会对资源进行检查,是静态资源则交给默认的servlet处理
具体查看 : https://www.cnblogs.com/dflmg/p/6393416.html

注解驱动

<mvc:annotation-driven/>

简单说加了这个标签使我们的注解能够起作用
具体查看:https://my.oschina.net/u/1156626/blog/881483

配置文件加载

<context:property-placeholder location="classpath*:config.properties"/>

加载我们外部配置的文件参数 取值方式:${rabbitmq.host}
具体查看 : https://blog.csdn.net/Rickesy/article/details/50791534

猜你喜欢

转载自blog.csdn.net/ftdd_hw/article/details/80463815