1 Spring4 之环境搭建和HelloWorld
1 Spring 是什么?
|
Spring模块图:

Eclipse开发Spring时需要安装spring插件:springsource-tool-suite-3.6.3.RELEASE-e4.4.1-updatesite.zip(下载链接:http://spring.io/tools/sts/all 需要FQ)。
2 安装 Eclipse插件
Eclipse—->help—> install new software : 点击Add按钮 ,再点击Archive 选择你刚刚下载的zip文件,这里选择 后面带 spring IDE的四项,并把Contact all updatesite….前面的勾去掉(这个是联网更新),一直点点击 下一步, 最后重启eclipse即可

3 搭建Spring开发环境
新建Java工程 :命名spring-1;并新建Folder 命名为lib(放Spring基本的jar包)
在lib中导入:commons-logging-1.1.3.jar在struts的lib中可以找到,其余四个都在spring-framework-4.1.2.RELEASE的libs文件夹下,记得将lib下的jar包add Build Path;

4 项目结构图:

其中HelloWorld.java
|
package com.bai.spring.beans; public class HelloWorld { private String name; public void setName(String name){ this.name=name; } public void hello(){ System.out.println("hello:"+name); } } |
在src下新建spring配置文件,命名为applicationcontext.xml:
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="helloworld" class="com.bai.spring.beans.HelloWorld"> <property name="name" value="Spring"></property> </bean> </beans> |

Main.java
|
package com.bai.spring.beans; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; public class Main { public static void main(String []args){ /* 不使用springde 情况 * //创建一个HelloWorld对象 HelloWorld helloworld=new HelloWorld(); //为对象赋值 helloworld.setName("baixl"); //调用hello()方法 */ ApplicationContext ctx=new ClassPathXmlApplicationContext("applicationcontext.xml"); HelloWorld helloworld=(HelloWorld) ctx.getBean("helloworld"); helloworld.hello(); } } |
运行结果:

1 Spring4 之环境搭建和HelloWorld的更多相关文章
- Scala深入浅出实战经典---001-Scala开发环境搭建和HelloWorld解析
001-Scala开发环境搭建和HelloWorld解析 Scala 函数式编程和面向对象结合的语言 函数式编程擅长数值计算 面向对象擅长大型工程和项目的组织以及团队的分工协作 Scala会是下一个伟 ...
- Android开发-环境搭建以及HelloWorld
最近开始进行Android的开发,没有基础完全从0开始. 首先,知道Android开发的官方网站: http://developer.android.com/index.html 网站本身教程非常 ...
- 【Android开发】之Android环境搭建及HelloWorld
原文链接:http://android.eoe.cn/topic/android_sdk Android开发之旅:环境搭建及HelloWorld Android开发之旅:环境搭建及HelloWorld ...
- Android最简单的实例 :环境搭建及HelloWorld
Android开发之旅:环境搭建及HelloWorld 2010-04-12 00:45 by 吴秦, 883961 阅读, 140 评论, 收藏, 编辑 ——工欲善其事必先利其器 引言 本系列适合 ...
- 转:Android开发之旅:环境搭建及HelloWorld
http://www.cnblogs.com/skynet/archive/2010/04/12/1709892.html 引言 本系列适合0基础的人员,因为我就是从0开始的,此系列记录我步入Andr ...
- Android开发之旅:环境搭建及HelloWorld
引言 本系列适合0基础的人员,因为我就是从0开始的,此系列记录我步入Android开发的一些经验分享,望与君共勉!作为Android队伍中的一个新人的我,如果有什么不对的地方,还望不吝赐教. 在开始A ...
- 【转】Android开发之旅:环境搭建及HelloWorld
原文网址: http://www.cnblogs.com/skynet/archive/2010/04/12/1709892.html 引言 本系列适合0基础的人员,因为我就是从0开始的,此系列记录我 ...
- Android环境搭建与HelloWorld
引言 本系列适合0基础的人员,因为我就是从0开始的,此系列记录我步入Android开发的一些经验分享,望与君共勉!作为Android队伍中的一个新人的我,如果有什么不对的地方,还望不吝赐教. 在开始A ...
- Android开发之旅:环境搭建及HelloWorld(转)
本系列适合0基础的人员,因为我就是从0开始的,此系列记录我步入Android开发的一些经验分享,望与君共勉!作为Android队伍中的一个新人的我,如果有什么不对的地方,还望不吝赐教. 在开始Andr ...
随机推荐
- CodeForces 869B
Even if the world is full of counterfeits, I still regard it as wonderful. Pile up herbs and incense ...
- kali2.0安装虚拟机工具
kali2.0无法安装虚拟机工具,显示VMware Tools无法用于该虚拟机,或者安装之后无法进行复制.粘贴等操作. 解决办法: step1: 更换源 root@starnight:~# vim / ...
- 基于canvas的图片编辑合成器
在我们日常的前端开发中,经常会要给服务器上传图片,但是局限很大,图片只能是已有的,假设我想把多张图片合成一张上传就需要借助图片编辑器了,但是现在我们有了canvas合成就简单多了 首先我们看图片编辑器 ...
- Hibernate总结之Hello,World
1. 引入相关maven依赖: <dependency> <groupId>org.hibernate</groupId> <artifactId>hi ...
- 黑色的网站后台管理系统ui界面——后台
链接:http://pan.baidu.com/s/1pLffwE3 密码:m4v6
- DataFrame衍生新特征操作
1.DataFrame中某一列的值衍生为新的特征 #将LBL1特征的值衍生为one-hot形式的新特征 piao=df_train_log.LBL1.value_counts().index #先构造 ...
- device tree --- #address-cells and #size-cells property
device tree source Example1 / { #address-cells = <0x1>; // 在 root node 下使用 1 個 u32 來代表 address ...
- LAMP网站架构解释
对于大流量.大并发量的网站系统架构来说,除了硬件上使用高 性能的服务器.负载均衡.CDN等之外,在软件架构上需要重点关注下面几个环节:使用高性能的操作系统(OS).高性能的网页服务器(Web Serv ...
- 杂乱的code
/*o(n)的堆化方法*/ void myjust(vector<int>& A,int i){ int l=i*2+1; int r=i*2+2; int minn=i; if( ...
- javascript当中的this详解
总结this的3个规则: this是调用上下文,上下文被创建或者初始化时才确定 非严格模式:this是全局对象:严格模式:this是undefined 函数调用 a. 以函数形式调用的函数通常不使用t ...