Spring学习笔记(二):Spring在STS中的配置和入门例子
来源:互联网 发布:javascript 是什么 编辑:程序博客网 时间:2024/06/05 17:26
1、入门例子的步骤:
(1)导入jar包:
下载地址:http://pan.baidu.com/s/1jGKj53K(版本3.0)
(2)在src中创建一个applicationContext.xml配置文件:
<?xml version="1.0" encoding="UTF-8"?><beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.springframework.org/schema/beans" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"><bean id="hello" class="hello.Hello"><property name="hello" value="hha"></property></bean></beans>
(3)在src中创建一个hello包,添加三个java,
hello.java
package hello;public class Hello implements HelloImpl{private String hello;public void setHello(String hello){this.hello=hello;}public void sayHello(){System.out.print(hello);}}helloImpl.java接口类
package hello;public interface HelloImpl {public void sayHello();}
test.java测试类
package hello;import org.springframework.context.ApplicationContext;import org.springframework.context.support.ClassPathXmlApplicationContext;public class test {public static void main(String[] args) {// TODO Auto-generated method stubApplicationContext app=new ClassPathXmlApplicationContext("applicationContext.xml");Hello hello=(Hello)app.getBean("hello");hello.sayHello();}}完成:运行即可;
0 0
- Spring学习笔记(二):Spring在STS中的配置和入门例子
- 【SSH】Spring学习(二)使用注解配置Spring、安装STS插件、Spring与junit整合测试、AOP
- Spring学习笔记(二十六):STS导入项目出错,提示找不到javax.servlet....
- Spring学习笔记(二十七):STS中Project Facets的作用
- Spring学习笔记(二)AOP入门
- 学习笔记-Spring入门(二)
- Spring学习笔记(二)Bean配置
- spring学习(二)Spring 中的 Bean 配置
- Spring学习笔记(二)----Spring AOP配置与应用
- Spring学习笔记(二十三):关于STS提示"javax.servlet.http.HttpServletRequest cant be resolved"的问题
- Spring学习笔记(十五):STS自带的maven老出错,如何配置单独的maven
- Spring入门笔记(二)
- SpringMVC入门--安装spring STS
- Spring学习笔记(一)--Spring入门和使用
- 在Eclipse和STS集成Cloud Foundry开发环境,spring + MongoDB 示例代码演示部署(二)
- Spring入门学习(二)
- Spring学习笔记(一)Spring入门
- Spring beans配置方案(二) 学习笔记
- Minimum Depth of Binary Tree
- 深度学习-LeCun、Bengio和Hinton的联合综述
- 开发iOS SDK注意事项
- 黑马程序员——字符流
- 南阳
- Spring学习笔记(二):Spring在STS中的配置和入门例子
- UML基础: 统一建模语言简介
- 自定义微博小尾巴(源码+解析)
- GRE北美范文:统一课程与多样化课程比较
- 莱恩6878棋牌游戏程序源码下载完整无错网狐免费下载
- 优化UITableViewCell高度计算
- 不使用临时变量交换两个变量的值(异或,加减,乘除)
- Java Collection之Queue详解及用途
- 04-树6. Huffman Codes (30)