您的位置:首页 > 编程语言 > Java开发

Web项目Spring基本配置

2018-03-29 17:31 253 查看
1、如果项目全程使用Spring注解来完成依赖注入,则需要在Spring基本配置文件中声明注解解释器,配置注解扫描包路径

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
...
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd ...
<context:annotation-config/>

<!-- 使用该配置上条配置可省略 -->
<context:component-scan base-package="com.meng"/>
</beans>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: