01_Spring3.2_Helloworld
来源:互联网 发布:snmp网管软件 编辑:程序博客网 时间:2024/05/09 13:46
正学习spring,把代码发到网上,希望大家能指出我的问题和缺点,如果能帮助到别人,就更happy了。
package cn.lichen;public class User {private String name;@Overridepublic String toString() {return "my name is " + name;}public User() {System.out.println("constructor...");}public void setName(String name) {System.out.println("setPorperty....");this.name = name;}}
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <bean id="user" class="cn.lichen.User"> <property name="name" value="LiChen"></property> </bean></beans>
package cn.lichen;import org.junit.Test;public class TestUser {@Testpublic void testToString() {BeanFactory factory = new ClassPathXmlApplicationContext("applicationContext.xml");User user = (User) factory.getBean("user");System.out.println(user.toString());;}}
注意junit4.11.jar版本必须和hamcrest-all.jar一起不然报错。java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing
- 01_Spring3.2_Helloworld
- java基础2_helloWorld
- D3.js学习01_HELLOWORLD
- 02_Spring3.2_属性类型设值注入
- 02_Spring3.2_属性类型构造注入
- 【JAX-WS入门系列】第01章_HelloWorld
- 2016716_HelloWorld
- JNI整理_helloworld(1)
- ruby入门_HelloWorld
- JavaScript初探之一_HelloWorld
- Linux内核模块_helloworld
- C#_HelloWorld 篇
- Struts2_01_Action简介_HelloWorld
- 4_HelloWorld项目整个过程
- C4GPLT_L1-001_HelloWorld
- Java入门笔记1_HelloWorld
- jbpm学习笔记(1)_HELLOWorld
- cocos2d-x 快速入门_HelloWorld
- std::string
- 关于结构体指定位数
- 名词解释“缓存穿透”和“缓存雪崩”
- 雅虎网站页面性能优化的34条黄金守则
- 商务名片创意搜罗
- 01_Spring3.2_Helloworld
- 树形控件右键菜单
- C# winfrom label 控件背景颜色自定义RGB 值
- 02_Spring3.2_属性类型设值注入
- 漫画研发之八:会哭的孩子有奶吃
- 追本溯源——JAVA中为什么float型最大值大于long型?
- 计算机视觉、机器学习相关领域论文和源代码大集合(转)
- java解析properties文件
- Linux终端中使用上一命令减少键盘输入