标签:xml 配置文件 Spring jar 003 暂记 array public mathrm
j a r 包 ( 4 + 1 ) { 4 个 核 心 b e a n , c o r e , c o n t e x t , e x p r e s s i o n 1 个 依 赖 c o m m o n . l o g g i n g . j a r 日 志 jar包(4+1) \left\{\begin{array}{l}4个核心 bean ,core,context,expression\\1个依赖 common.logging.jar日志\end{array}\right. jar包(4+1){4个核心bean,core,context,expression1个依赖common.logging.jar日志
public interface UserService{
public void addUsre();
}
public class UserServiceImpl implments UserService {
public void addUsre(){输出语句};
}
测试类
public class TestIoc{
//原来的方式
UserService userService =new UserSviceImpl();
userService .addUser();
//现在的方式
//容器
String xmlpath =“com.···.beans.xml”
ApplicationContext applicationContext= new ClassPathXmlApplicationContext(xmlpath);
//对象
UserSersvice userSvice =(UserSvice)applicationContext.getBean(“UsersvicesID”)
userSvice .adduser();
}
配置文件.xml(可用注解取代)
配 置 文 件 { 位 置 : 任 意 , 常 在 c l a s s p a t h 下 ( s r c 下 ) 名 称 : 任 意 , 如 b e a n s . x m l 常 用 a p p l i c a t i o n c o n t e x t . x m l 内 容 : s c h e m a 约 束 < b e a n i d = " S e r v i c e I d " c l a s s = " . S e r v i c e I m p l " > < / b e a n > \mathrm{配置文件}\left\{\begin{array}{l}\mathrm{位置}\;:\;\mathrm{任意,常在classpath下(src下)}\\\mathrm{名称}\;:\;\mathrm{任意,如}beans.xml\;\mathrm{常用}applicationcontext.xml\\\mathrm{内容}\;:\;schema\mathrm{约束 <bean id="ServiceId" class=" ~.ServiceImpl"> </bean>}\end{array}\right. 配置文件⎩⎨⎧位置:任意,常在classpath下(src下)名称:任意,如beans.xml常用applicationcontext.xml内容:schema约束<beanid="ServiceId"class=" .ServiceImpl"></bean>
标签:xml,配置文件,Spring,jar,003,暂记,array,public,mathrm 来源: https://blog.csdn.net/ResumeProject/article/details/112813987
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。