这是一个spring入门demo:

package com.su.test;

public class HelloWorld {

    public void say(){
System.out.println("Spring4!");
}
}
package com.su.service;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext; import com.su.test.HelloWorld; public class Test {
public static void main(String[] args) {
  //通过xml配置文件来获取对象,而非使用new
ApplicationContext ac=new ClassPathXmlApplicationContext("beans.xml");
HelloWorld helloWorld=(HelloWorld)ac.getBean("helloWorld");
helloWorld.say();
}
}
<?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.su.test.HelloWorld"></bean> </beans>

Spring学习01——HelloSpring的更多相关文章

  1. spring学习(01)之IOC

    spring学习(01)之IOC IOC:控制反转——Spring通过一种称作控制反转(IOC)的技术促进了低耦合.当应用了IOC,一个对象依赖的其它对象会通过被动的方式传递进来,而不是这个对象自己创 ...

  2. Spring学习01(IOC)

    1.Spring概述 简介 2002年,Rod Jahnson首次推出了Spring框架雏形interface21框架. 2004年3月24日,Spring框架以interface21框架为基础,经过 ...

  3. Spring学习-01

    一.Srping 一个轻量级DI.IOC.AOP的容器框架 DI:依赖注入 IOC:控制反转 AOP:面向切面 二.构造器注入 Constructor-arg 属性:index/name/type/r ...

  4. Spring 学习01

    一.Spring概念 1 spring是开源的轻量级框架 2 spring核心主要两部分: (1)aop:面向切面编程,扩展功能不是修改源代码实现 (2)ioc:控制反转, - 比如有一个类,在类里面 ...

  5. 我的Spring学习记录(二)

    本篇就简单的说一下Bean的装配和AOP 本篇的项目是在上一篇我的Spring学习记录(一) 中项目的基础上进行开发的 1. 使用setter方法和构造方法装配Bean 1.1 前期准备 使用sett ...

  6. Spring学习之——手写Spring源码V2.0(实现IOC、D、MVC、AOP)

    前言 在上一篇<Spring学习之——手写Spring源码(V1.0)>中,我实现了一个Mini版本的Spring框架,在这几天,博主又看了不少关于Spring源码解析的视频,受益匪浅,也 ...

  7. Python学习--01入门

    Python学习--01入门 Python是一种解释型.面向对象.动态数据类型的高级程序设计语言.和PHP一样,它是后端开发语言. 如果有C语言.PHP语言.JAVA语言等其中一种语言的基础,学习Py ...

  8. spring 学习之 bean 的注入方式 property和constructor-arg的使用方式

    spring 学习之 bean 的注入方式 property和constructor-arg的使用方式. bean的注入方式: property 注入是: 通过setxx方法注入. construct ...

  9. Java虚拟机JVM学习01 流程概述

    Java虚拟机JVM学习01 流程概述 Java虚拟机与程序的生命周期 一个运行时的Java虚拟机(JVM)负责运行一个Java程序. 当启动一个Java程序时,一个虚拟机实例诞生:当程序关闭退出,这 ...

随机推荐

  1. “百度杯”CTF比赛 十一月场--CrackMe01

    测试文件:https://static2.ichunqiu.com/icq/resources/fileupload/CTF/BSRC/BSRC-11-3/CrackMe01_97D2BF0DBD2E ...

  2. JS 的 Array 和String 常混淆方法

    知识一: 1.slice() 提取字符串 slice[ start, end) 如果参数为负数,表示从尾部开始算起. 2.subString() 提取字符串 3.subStr() 提取字符串 subS ...

  3. Django rest_frameword 之项目流程

    后端开发软件目录规范 一.Model from django.db import models # Create your models here. # 多表的设计 # 图书 作者 出版社 作者详情表 ...

  4. rest_framework框架的分页

    class MyPageNumberPagination(PageNumberPagination): page_size = 1 page_query_param = 'page' page_siz ...

  5. The Complex Inversion Formula. Bromwich contour.

    网址:http://www.solitaryroad.com/c916.html

  6. react:如何创建一个新项目

    如何用react创建一个新的项目 我们打开react官网:https://reactjs.org/docs/create-a-new-react-app.html 看到以下命令 npx create- ...

  7. MyEclipse使用教程:使用Workbench和Perspectives

    [MyEclipse CI 2019.4.0安装包下载] workbench指的是加载IDE时看到的内容,它通常包含一个perspective,这是相关视图和编辑器的布局.您可以根据正在进行开发的类型 ...

  8. man gzip

    GZIP(1)                                                                GZIP(1) NAME/名称       gzip, g ...

  9. Spring配置文件出错

    问题描述: Element 'xxxxxxx' cannot have character [children],because the type's content type is element- ...

  10. java mar --->JSONArray.fromObject

    <dependency> <groupId>net.sf.json-lib</groupId> <artifactId>json-lib</art ...