0. 环境准备

1) jar包

jar包我会帮大家准备好的,所以不用担心找不到Jar包  链接:https://pan.baidu.com/s/1JJcYaspK07JL53vU-q-BUQ 提取码:1028 

c3p0-0.9.1.2.jar

commons-logging-1.1.1.jar

mysql-connector-java-5.1.7-bin.jar

spring-aop-4.0.0.RELEASE.jar

spring-beans-4.0.0.RELEASE.jar

spring-context-4.0.0.RELEASE.jar

spring-core-4.0.0.RELEASE.jar

spring-expression-4.0.0.RELEASE.jar

1. applicationContext.xml

1     <!-- 配置bean -->
2 <bean id="helloworld" class="com.cnblogs.www.pluto.Spring">
3 <property name="name" value="Spring"></property>
4 </bean>

SpringBean

2. HelloWorld.java

 1 public class HelloWorld {
2
3 private String name;
4
5 public void setName(String name) {
6 System.out.println("setname: "+name);
7 this.name = name;
8 }
9
10 public void hello() {
11 System.out.println("hello "+name);
12 }
13
14 public HelloWorld() {
15 System.out.println("helloworld's constructor...");
16 }
17
18 }

HelloWorld

3. Main.java

 1 import org.springframework.context.ApplicationContext;
2 import org.springframework.context.support.ClassPathXmlApplicationContext;
3
4 public class Main {
5
6 public static void main(String[] args) {
7 // TODO Auto-generated method stub
8 /*
9 HelloWorld helloWorld = new HelloWorld();
10 helloWorld.setName("pluto");
11 helloWorld.hello();
12 */
13
14 //1.创建Spring的IOC容器对象
15 ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
16 //2.从IOC容器中获取Bean实例
17 HelloWorld helloWorld = (HelloWorld) ctx.getBean("helloworld");
18 //3.调用hello方法
19 System.out.println(helloWorld);
20 helloWorld.hello();
21 }
22
23 }

Main

02、Spring-HelloWorld的更多相关文章

  1. 一、spring——helloWorld

    1.添加jar包,如下图所示: 2.建立spring项目,如下图所示: 3.验证,如下图所示:

  2. 02 浅析Spring的AOP(面向切面编程)

    1.关于AOP AOP(Aspect Oriented Programming),即面向切面编程,可以说是OOP(Object Oriented Programming,面向对象编程)的补充和完善.O ...

  3. 一、Spring Boot 入门

    1.Spring Boot 简介 简化Spring应用开发的一个框架: 整个Spring技术栈的一个大整合: J2EE开发的一站式解决方案: 2.微服务 2014,martin fowler 微服务: ...

  4. 1、spring boot入门

    1.Spring Boot 简介 简化Spring应用开发的一个框架: 整个Spring技术栈的一个大整合: J2EE开发的一站式解决方案: 2.微服务 2014,martin fowler 微服务: ...

  5. 星舟平台的使用(GIT、spring Boot 的使用以及swagger组件的使用)

    一.介绍星舟平台     1.星舟简介     2.网关kong的介绍     3.客户端         1).服务注册:Eureka         2).客户端负载均衡:Ribbon     4 ...

  6. 任务调度(02)Spring Schedule

    任务调度(02)Spring Schedule [toc] Spring 3.0 提供两种任务调度方式:一是定时任务调度:二是异步任务调度.这两种任务调度方式都是基于 JUC 实现的,是一种非常轻量级 ...

  7. 一、spring 环境搭建

    一.springtoolSuite4下载 1.概述 Spring Tools 4 是适用于您最喜欢的编码环境的下一代 Spring 工具.它主要从头开始重建,为开发基于 Spring 的企业应用程序提 ...

  8. spring自动扫描、DispatcherServlet初始化流程、spring控制器Controller 过程剖析

    spring自动扫描1.自动扫描解析器ComponentScanBeanDefinitionParser,从doScan开始扫描解析指定包路径下的类注解信息并注册到工厂容器中. 2.进入后findCa ...

  9. 1、Spring In Action 4th笔记(1)

    Spring In Action 4th笔记(1) 2016-12-28 1.Spring是一个框架,致力于减轻JEE的开发,它有4个特点: 1.1 基于POJO(Plain Ordinary Jav ...

  10. 转 Netflix OSS、Spring Cloud还是Kubernetes? 都要吧!

    Netflix OSS.Spring Cloud还是Kubernetes? 都要吧! http://www.infoq.com/cn/articles/netflix-oss-spring-cloud ...

随机推荐

  1. swoft实现自动重启服务 转

    目的:1.上传代码后HTTP服务自动重启,不需要自己手动执行:php bin/swoft http:start2.自动重启适用于开发调试阶段,因为不能再后台运行所以在线上环境的话还是要重启http服务 ...

  2. python 虚拟环境安装

    windows虚拟环境的搭建 安装 # 建议使用pip3安装到python3环境下 pip3 install virtualenv pip3 install virtualenvwrapper-win ...

  3. c++ 获取文件创建时间、修改时间、访问时间、文件内容长度

    int GetFileInfo(string& strPath, int& iCreateTime, int& iModifyTime, int& iAccessTim ...

  4. git -- Authentication failed for 报错如何解决?

    昨天拉代码拉不下来,报这个错误:fatal: Authentication failed for .... 有很多网上的解释是 $  git config --global --replace-all ...

  5. 使用creata-react-app脚手架创建react项目时非常慢的问题

    创建react项目必须要有下面两个步骤 cnpm install -g create-react-app  //创建react全局变量 create-react-app my-app //创建一个re ...

  6. vue中上拉加载数据的实现

    获取屏幕高度来判断数据的加载                                       效果是这样的

  7. chrome浏览器中调试窗口位置修改

    在这里修改就好了

  8. day04 Selenium请求库

    1.什么是Selenium?       Selenium是一个自动测试工具,它可以帮我通过代码去实现驱动浏览器自动执行相应的操作.       所以我们也可以用它来做爬虫.    2.为什么要适用s ...

  9. 使用 IDEA 查看 JDK8 源码

    使用 idea 查看 oracle jdk 8 源码时发现 Unsafe 没有源码. 解决方法: 到 openjdk-8 下载页面:http://jdk.java.net/java-se-ri/8-M ...

  10. python数据类型之tuple(元组)

    tuple元组 关注公众号"轻松学编程"了解更多. 1.概述 本质上是一种有序的集合,和列表非常的相似,列表使用[]表示,元组使用**()**表示. 特点:一旦初始化,就不能发生改 ...