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. docker系统化学习图文教程

    1.背景 在实际开发中我们经常遇到这样的情况: 1.开发的时候测试好的程序已发布到线上就出问题: 2.线上的集群环境需要扩容时非常麻烦,比如说要装jdk.mysql.redis等,如果扩容100台服务 ...

  2. pmm-server 搭建

    1 搭建docker centos 下 参考文档搭建docker  https://www.cnblogs.com/brady-wang/p/11543237.html docker create \ ...

  3. spring boot:使用redis cluster集群作为分布式session(redis 6.0.5/spring boot 2.3.1)

    一,为什么要使用分布式session? HpptSession默认使用内存来管理Session,如果将应用横向扩展将会出现Session共享问题, 所以我们在创建web集群时,把session保存到r ...

  4. nginx安全:用limit_req_zone/limit_req限制连接速率(流量控制/限流)

    一,limit_req的用途: 1,官方文档地址: http://nginx.org/en/docs/http/ngx_http_limit_req_module.html 2,用途: 限制用户在给定 ...

  5. centos8平台使用strace跟踪系统调用

    一,strace的用途 strace  是最常用的跟踪进程系统调用的工具. 说明:刘宏缔的架构森林是一个专注架构的博客,地址:https://www.cnblogs.com/architectfore ...

  6. selenium 浏览器标签切换

    from time import sleep from selenium import webdriver from selenium.webdriver.chrome.options import ...

  7. 3.QOpenGLWidget-通过着色器来渲染渐变三角形

    在上章2.通过QOpenGLWidget绘制三角形,我们学习绘制三角形还是单色的,本章将为三角形每个顶点着色.   1.着色器描述 着色器的开头总是要声明版本,接着是输入和输出变量.uniform和m ...

  8. 刷题不应该刷leecode 应该刷oj

    因为leecode有很多题目 表述不清 意义不明 最关键的是 leecode压根不规定输入输出的格式 这个完全不是竞赛的风格 这样会养成很多坏习惯

  9. Sec-Fetch-*请求头,了解下?

    如果你使用76+版本的chrome浏览器,通过开发者面板查看每个网络请求,会发现都有几个Sec-Fetch开头的请求头,例如访问百度首页https://www.baidu.com/的请求: Sec-F ...

  10. A. Arena of Greed 解析(思維)

    Codeforce 1425 A. Arena of Greed 解析(思維) 今天我們來看看CF1425A 題目連結 題目 略,請直接看原題. 前言 明明是難度1400的題目,但總感覺不是很好寫阿, ...