1) 工具: (1) jdk

(2) spring.jar  、commons-logging-1.1.1.jar (因为只是做的简单的demo,所以就只用这两个jar包)

spring.jar 是包含有完整发布模块的单个jar 包。但是不包括mock.jar, aspects.jar, spring-portlet.jar, and spring-hibernate2.jar。

commons-logging.jar 包是使用spring的必备包。用来记录程序运行时的活动的日志记录。

在IDE中导入jar后就可以开始编写测试了

2) 在src下写配置文件 

相关文件如下:spring-demo.xml

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xsi:schemaLocation="http://www.springframework.org/schema/beans
  5. http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
  6.  
  7. <bean id="testBean" class="com.gdut.springdemo.Spring">
  8. <property name="mySpring">
  9. <value>This is my first spring!</value>
  10. </property>
  11. </bean>
  12. </beans>

测试类:Spring.java

  1. package com.gdut.springdemo;
  2.  
  3. public class Spring {
  4. private String mySpring;
  5.  
  6. public void show(){
  7. System.out.println("--message--"+getMySpring());
  8. }
  9.  
  10. public String getMySpring() {
  11. return mySpring;
  12. }
  13. public void setMySpring(String mySpring) {
  14. this.mySpring = mySpring;
  15. }
  16. }

TestSpring.java

  1. package com.gdut.springdemo;
  2.  
  3. import org.springframework.context.ApplicationContext;
  4. import org.springframework.context.support.FileSystemXmlApplicationContext;
  5.  
  6. public class TestSpring {
  7. public static void main(String[] args) {
  8. ApplicationContext ctx=new FileSystemXmlApplicationContext("src/spring-demo.xml");
  9. Spring spring=(Spring) ctx.getBean("testBean");
  10. spring.show();
  11. }
  12.  
  13. }

控制台打印: --message--This is my first spring!

eclipse下的spring环境配置的更多相关文章

  1. windows7+eclipse+hadoop2.5.2环境配置

    windows7+eclipse+hadoop2.5.2环境配置    一.hadoop集群环境配置 参考我的前一篇文章(ubuntu + hadoop2.5.2分布式环境配置 http://www. ...

  2. windows下spark开发环境配置

    http://www.cnblogs.com/davidwang456/p/5032766.html windows下spark开发环境配置 --本篇随笔由同事葛同学提供. windows下spark ...

  3. deepin linux 下C开发环境配置

    # deepin linux 下C开发环境配置 ## 前言-----------------------------deepin操作系统商店默认提供了 eclipse for c\c++但是系统没有提 ...

  4. 【Objective-C】Windows下Objective-C开发环境配置

    [Objective-C]Windows下Objective-C开发环境配置 ftp://ftpmain.gnustep.org/pub/gnustep/binaries/windows/   最近打 ...

  5. windows下apache+https环境配置

    windows下apache+https环境配置 转 https://www.cnblogs.com/sandaizi/p/7519370.html 1.修改配置文件conf/httpd.conf,去 ...

  6. Linux—CentOS7下python开发环境配置

    CentOS7下python开发环境配置 上一篇博客讲了如何在Centos7下安装python3(https://www.cnblogs.com/zivli/p/9937608.html),这一次配置 ...

  7. Metabase在Windows下的开发环境配置

    Metabase在Windows下的开发环境配置 */--> pre.src {background-color: #292b2e; color: #b2b2b2;} Metabase在Wind ...

  8. Linux下安装Java环境配置

    1.下载安装文件 下载地址:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html 2. ...

  9. Ubuntu 16.04下的LAMP环境配置

    在学习开发过程中,每当遇到新的问题时,通常都能在网上搜到解决的方法,但是网上的方法千千万,有些是已经过时了的,有些是跟自己开发环境不同的,总是不能第一时间能找到答案. 而当时遇到的问题可能在今后的开发 ...

随机推荐

  1. 转:Java中的String,StringBuilder,StringBuffer三者的区别

    最近在学习Java的时候,遇到了这样一个问题,就是String,StringBuilder以及StringBuffer这三个类之间有什么区别呢,自己从网上搜索了一些资料,有所了解了之后在这里整理一下, ...

  2. Codeforces Round #542 C. Connect 搜索

    C. Connect time limit per test 1 second memory limit per test 256 megabytes input standard input out ...

  3. java kafka单列模式生产者客户端

    1.所需要的依赖 <?xml version="1.0" encoding="UTF-8"?> <project xmlns="ht ...

  4. Linux内核入门到放弃-锁与进程间通信-《深入Linux内核架构》笔记

    内核锁机制 对整数的原子操作 <asm-arch/atomic.h> typedef struct {volatile int counter;} atomic_t; //初始化只能借助于 ...

  5. Golang 爬虫-广度优先(获取html文档中的超链接)

    package main import( "fmt" "net/http" "io/ioutil" "regexp" & ...

  6. C++ —— 返回数组指针的函数 和 返回指向函数的指针的函数

    返回数组指针的函数 基础知识:数组不能被拷贝,函数不能返回数组,只能返回数组的指针或者引用. 定义一个 返回数组指针的函数 的方法,以 一个接收参数为 含有10个整型元素的数组的引用  和 返回一个含 ...

  7. .net core 简单项目的创建

    1.linux 安装net coref https://www.microsoft.com/net/learn/get-started/linuxubuntu 2.创建目录 2.创建控制台项目 第一次 ...

  8. VS2015/Visual Studio快捷键无效问题

    0 VS2015快捷键无效问题的解决办法 快捷键的使用可以大大提高编码效率,VS为我们内置了不少的常用快捷键组合,实际使用过程中往往会随着计算机上安装其他软件引起快捷键冲突,导致VS快捷键失效,解决办 ...

  9. Spring-boot 编写hello world

    项目启动时出现如下报错信息: Unrecognized VM option 'TieredStopAtLevel=1' Could not create the Java virtual machin ...

  10. router-link 绑定事件的方式

    实现方法如下  使用.native 实现原生事件 <router-link to="" @click.native="dialogWithdraw=true&quo ...