美文网首页
Spring的开发步骤

Spring的开发步骤

作者: 打死你的小白兔 | 来源:发表于2018-03-29 10:29 被阅读0次

1、引入spring jar包
2、添加applicationContext.xml
3、创建一个javabean里面属性有set get方法即可
4、配置applicationContext.xml
<bean id="he" class="entity.Hello">
<property name="hello" value="我爱中国!!!"></property>
</bean>
5、开发测试
ApplicationContext ac=new ClassPathXmlApplicationContext("applicationContext.xml");
Hello bean1 = (Hello) ac.getBean("he");//第1种获取bean方式,需要强转
Hello bean2 = ac.getBean("he", Hello.class);//第2种获取bean方式
System.out.println(bean1.getHello());

相关文章

网友评论

      本文标题:Spring的开发步骤

      本文链接:https://www.haomeiwen.com/subject/hdzpcftx.html