Spring-01
来源:互联网 发布:c语言中文网vip百度云 编辑:程序博客网 时间:2024/06/05 23:00
1)下载spring 和common.logging日志包
2)新建javaproject项目,新建lib目录
3)将spring lib下的spring-beans-4.1.3.BUILD-SNAPSHOT.jar
spring-context-4.1.3.BUILD-SNAPSHOT.jar
spring-core-4.1.3.BUILD-SNAPSHOT.jar
spring-expression-4.1.3.BUILD-SNAPSHOT.jar
和commons-logging-1.2.jar
引入,进行buildpath,加入引用库
4)创建helloWorld文件,
public class HelloWorld {
private String name;
public void setName(String name) {
this.name=name;
}
public void hello() {
System.out.println("hello"+name);
}
}
5)在src下创建applicationContext.xml,设置beans
<?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="helloworld" class="com.yc.spring.beans.HelloWorld">
<property name="name" value="Spring"></property>
</bean>
</beans>
6)在测试类下
1.构造ioc容器
ApplicationContext ctx=new ClassPathXmlApplicationContext("applicationContext.xml");
2.获取bean对象
ctx.getBean("helloworld");
3.调用方法
- spring 01 -spring初始
- Spring--01
- spring 01
- Spring 01
- Spring-01
- Spring入门01 - 简介 Spring
- Spring笔记01-Spring概览
- 01spring spring的简单模拟
- Spring MVC 01 - Spring MVC框架介绍
- spring学习笔记01-spring入门
- Spring学习笔记01
- 01-Spring发送邮件
- Spring 学习笔记01
- Spring入门01
- 01、Spring jar 下载
- Spring 从零开始-01
- Spring-01-HelloWorld
- Spring-01-HelloWorld
- phpPHP创建创建jpg格式图片以及压缩图片
- 6-LTE Security II: NAS and AS Security
- 初入c++
- Java+opencv3.2.0之模板匹配
- Redis与Memcached的区别
- Spring-01
- 在CentOS6.5环境下编译安装MySQL5.6.34
- 数百种编程语言,而我为什么要学 Python?
- jQuery学习笔记
- MessageFormat.format使用方法
- Linux 是否已征服云端?
- 【转】CNN卷积神经网络_ GoogLeNet 之 Inception(V1-V4)
- RIOT-Nucleo-144 系列板的运行
- c#之static关键字