Spring 的Helloworld
来源:互联网 发布:硕鼠mac下载 编辑:程序博客网 时间:2024/06/03 10:49
导入jar 包
1. 项目结构:
~~~~~~~~~~~~~~~~~~~~~~~~~分割线~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Person.java
package com.baidu.spring.beans.test;public class Person {private String name;public void setName(String name) {this.name = name;}public void showName() {System.out.println("Person's name: " + name);}}applicationContext.xml
<?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 --><bean id="person" class="com.baidu.spring.beans.test.Person"><property name="name" value="LiLei"></property></bean></beans>TestSpringPerson.java
package com.baidu.spring.beans.test;import org.springframework.context.ApplicationContext;import org.springframework.context.support.ClassPathXmlApplicationContext;public class TestSpringPerson {public static void main(String[] args) {//1. 创建Spring 的IOX 容器对象ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml");//2. 从容器中 获取bean 实例 Person person = (Person) ac.getBean("person");//3. 调用person de showName()方法person.showName();}}
0 0
- Spring的HelloWorld
- Spring 的Helloworld
- spring的HelloWorld<01>
- spring的HelloWorld
- Spring的HelloWorld
- spring的helloworld
- Spring.Net 的简单HelloWorld
- 最简单的Spring HelloWorld
- Spring MVC版本的helloworld
- spring的入门之helloworld
- Spring学习(二):Spring的HelloWorld
- Spring helloworld
- spring helloworld
- spring helloworld
- Spring -- HelloWorld
- spring helloworld
- Spring HelloWorld
- Spring--HelloWorld
- 一个32岁入门的70后程序员给我的启示
- Python - 子类继承父类 和 Java有什么区别
- leetcode总结_链表
- Pascal's Triangle II
- 《CSS权威指南》学习记录——定位(二)
- Spring 的Helloworld
- UNIX环境高级编程-第1章复习-时间获取客户端和服务器
- java处理mysql里面字段的空值
- 前序,中序写出后向遍历,中序,后序写前序
- Sencha Touch MVC 中 store 的使用
- (六)JavaScript Array对象及方法
- 当下要真硬着性子把Android学下去, 定会是移动互联台上的角儿
- 通过U盘的盘符找到USB设备
- Range——删除内容的某些文字