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. centos8平台安装redis6.0.1

    一,redis的官网: https://redis.io/ redis6于5月3日正式发布,它的新增功能: acl 多线程io cluster proxy resp3协议 本文演示redis6.0.1 ...

  2. php进程 swoole

    <?php $pid = posix_getpid(); $ppid = posix_getppid(); var_dump($pid); cli_set_process_title(" ...

  3. SOAP调用Web Service

    SOAP调用Web Service (示例位置:光盘\code\ch07\ WebAppClient\ JsService4.htm) <html xmlns="http://www. ...

  4. vue学习笔记(一)---- vue指令( v-bind 属性绑定 )

    看栗子: <body> <div id="app"> <input type="button" value="按钮&qu ...

  5. LeakCanary检测内存泄漏

    内存泄漏原因: 线程造成的内存泄漏 Handler造成的内存泄漏 单例导致内存泄露 静态变量导致内存泄露 非静态内部类导致内存泄露 未取消注册(BroadcastReceiver )或回调导致内存泄露 ...

  6. tf-tensorboard的一些注意事项

    tensorboard --logdir = 绝对路径 1.注意的是绝对路径里面不能有中文 2. tensorboard  文件应放在一个最小子目录中

  7. 微信小程序日历签到

    近日做了一个项目需要用到日历插件,在网上找了一部分感觉跟项目不对口,所以就查考了其他的日历插件做了一个. 需求: 如图: 代码如下: index.wxml: <!--pages/pictrues ...

  8. Docker composer搭建Spring Cloud Alibaba 运行环境(二)

    " Spring Cloud Alibaba要用到的组件很多,注册中心nacos, 限流sentinel, 数据库,网关等等.由于用到的组件相对较多,部署会很繁琐,最关键的是没有资源服务器, ...

  9. MVC IIS 403.14

    描述:HTTP Error 403.14 - Forbidden The Web server is configured to not list the contents of this direc ...

  10. centos7安装mongodb4.0教程

    1.配置软件仓库: vim /etc/yum.repos.d/mongodb-org-4.0.repo [mongodb] name=MongoDB baseurl=https://repo.mong ...