加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

通过配置xml文件的方式将Classpath下的类交给Sping容器管理

发布时间:2020-12-16 05:29:24 所属栏目:百科 来源:网络整理
导读:?xml version="1.0" encoding="UTF-8"?beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" span style="white-space:pre"/spanxmlns:context="http://www.springframework.org/schema/contex
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
<span style="white-space:pre">	</span>xmlns:context="http://www.springframework.org/schema/context"
	xsi:schemaLocation="http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
           http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">
	<context:component-scan base-package="包名"/>
</beans>

注意:报名不一定是完整的包名,例如所有的包名以com开头,则通过以下配置可以将所有的类让Spring容器管理<context:component-scan base-package="com"/

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读