Spring 开发第一步
经过今天上午的学习发现spring上手开发一个"hello world"真的非常简单。
开发环境搭建:
1、去spring官网下载spring-framework-3.2.11.RELEASE-dist.zip 。这里带dist的是二进制的jar包,不带dist的是源代码
2、eclipse下新建一个java项目,把上面的包解压后的jar都引用到项目里去,还要再引入一个commons-logging.jar不然会报日志logging factory找不到的错误。
运行《spring in action 3rd Edition》chapter 2中的例子:

package com.springinaction.springidol;
public interface Performer {
void perform() throws PerformanceException;
}
package com.springinaction.springidol;
public class Juggler implements Performer{
private int bags = 3;
public Juggler(){
}
public Juggler(int bags){
this.bags = bags;
}
public void perform() throws PerformanceException{
System.out.println("Juggling "+ this.bags + " bags.");
}
}
<?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-3.0.xsd">
<!-- Beans declararions go here -->
<bean id="duke" class="com.springinaction.springidol.Juggler"></bean>
</beans>
ApplicationContext ctx = new ClassPathXmlApplicationContext("com/springinaction/springidol/spring-idol.xml");
Performer performer = (Performer)ctx.getBean("duke");
performer.perform();
运行结果:Juggling 3 bags.
Spring 开发第一步的更多相关文章
- Spring 开发第一步(三)Spring与JDBC
<spring in action 3rd>中的前面4章讲解的是Spring的核心,也就是DI/IOC和AOP .从第5章开始是Spring在企业开发中的各个方面的应用.其实作为笔者从事的 ...
- Spring 开发第一步(四)Spring与JDBC事务
Spring使用各种不同的TransactionManager来管理各种不同数据源事务底层(比如jdbc数据源.hibernate数据源.JPA数据源等等).在此基础上使用各种对应的Template来 ...
- Spring 开发第一步(二)
今天继续学习<Spring in action 3rd>并运行书中的例子,到了第4章aop,是加入一个作为切面的Audience类,将Performer的perform()方法作为切点来进 ...
- 我的自定义框架 || 基于Spring Boot || 第一步
今天在园子里面看到一位大神写的springboot做的框架,感觉挺不错,遂想起来自己还没有一个属于自己的框架,决定先将大神做好的拿过来,然后加入自己觉得需要的模块,不断完善 目前直接复制粘贴过来的,后 ...
- Andriod开发第一步-部署环境(搬运&&总结)
第一步:安装JDK 第二步:配置Windows上JDK的变量环境 第三步:下载安装Eclipse 第四步:下载安装Android SDK 配置了JDK变量环境, ...
- JAVA开发第一步 - JDK安装与配置
JDK的安装与环境变量配置是JAVA开发之路的第一步,很多新人在这一步上就卡了很久,浪费了很多时间,甚至有些人就轻易地“从入门到放弃”了.今天我们就来一步步教你如何打倒这第一只拦路虎. 1.JDK下载 ...
- JDK 安装与环境配置配置——Android开发第一步
什么是JDK? JDK 即 Java Development Kit,Java开发工具包,用来编译 Java 程序.JRE 在接触JDK的过程中,同时了解到 JRE,JRE 即 Java Runtim ...
- ios开发第一步--虚拟机安装MAC OS X
暂时还没买Macbook,先用虚拟机练练手. 先说说准备工作,我是在win8下安装的,这个不是关键的,只要Vmware版本和MAC OS X版本确定就行了,win7下同样可以. 1.虚拟机Vmware ...
- 安卓开发第一步:Android Studio安装配置
虽然本人是JAVA开发工程师平时主要开发Web App,但因为项目需求需要开发对应的移动端.一时又找不到合适的安卓开发人员,兄弟我只好被项目经理"抓来当壮丁了".俗话说好" ...
随机推荐
- [leetcode]543. Diameter of Binary Tree二叉树直径
Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a b ...
- [leetcode]278. First Bad Version首个坏版本
You are a product manager and currently leading a team to develop a new product. Unfortunately, the ...
- 【z】Storm - the world's best IDE framework for .NET
http://www.codeproject.com/Articles/42799/Storm-the-world-s-best-IDE-framework-for-NET Storm - the w ...
- dedecms目录说明
1.有多个common.inc.php文件,注意引入的是哪一个,引入以后,里面的常量才可以用: 2.路径向上跳转 require_once('../../plus/phpexcel/PHPExcel. ...
- [BAT] 执行xcopy命令后出现Invalid num of parameters错误的解决办法
如果是Windows下的命令行,对于有空格的文件路径要加引号,对于xcopy命令就是源路径和目标路径都要加引号 xcopy "C:\ppt" "D:\Program do ...
- mvc模拟实现
.定义httpmodule <system.webServer> <modules> <add name="UrlRoutingModule" typ ...
- oracle 表分区例子
oracle表分区详解-一步一步教你oracle分区表详解 .创建三个不同的表空间,模拟在不同磁盘上的保存不同范围的数据 create tablespace test01 datafile ...
- oracle存储过程结合我公司代码1
1. Framework.QueryInfo info1 = new Framework.QueryInfo(); //string Sql = Holwor ...
- com.opensymphony.xwork2.config.ConfigurationManager.addConfigurationProvider
一月 31, 2016 5:06:31 下午 org.apache.catalina.core.StandardContext filterStart 严重: Exception starting f ...
- pyspider示例代码六:传递参数
传递参数 示例一 #!/usr/bin/env python # -*- encoding: utf- -*- # vim: ts= sts= ff=unix fenc=utf8: # Created ...