02、Spring-HelloWorld
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的更多相关文章
- 一、spring——helloWorld
1.添加jar包,如下图所示: 2.建立spring项目,如下图所示: 3.验证,如下图所示:
- 02 浅析Spring的AOP(面向切面编程)
1.关于AOP AOP(Aspect Oriented Programming),即面向切面编程,可以说是OOP(Object Oriented Programming,面向对象编程)的补充和完善.O ...
- 一、Spring Boot 入门
1.Spring Boot 简介 简化Spring应用开发的一个框架: 整个Spring技术栈的一个大整合: J2EE开发的一站式解决方案: 2.微服务 2014,martin fowler 微服务: ...
- 1、spring boot入门
1.Spring Boot 简介 简化Spring应用开发的一个框架: 整个Spring技术栈的一个大整合: J2EE开发的一站式解决方案: 2.微服务 2014,martin fowler 微服务: ...
- 星舟平台的使用(GIT、spring Boot 的使用以及swagger组件的使用)
一.介绍星舟平台 1.星舟简介 2.网关kong的介绍 3.客户端 1).服务注册:Eureka 2).客户端负载均衡:Ribbon 4 ...
- 任务调度(02)Spring Schedule
任务调度(02)Spring Schedule [toc] Spring 3.0 提供两种任务调度方式:一是定时任务调度:二是异步任务调度.这两种任务调度方式都是基于 JUC 实现的,是一种非常轻量级 ...
- 一、spring 环境搭建
一.springtoolSuite4下载 1.概述 Spring Tools 4 是适用于您最喜欢的编码环境的下一代 Spring 工具.它主要从头开始重建,为开发基于 Spring 的企业应用程序提 ...
- spring自动扫描、DispatcherServlet初始化流程、spring控制器Controller 过程剖析
spring自动扫描1.自动扫描解析器ComponentScanBeanDefinitionParser,从doScan开始扫描解析指定包路径下的类注解信息并注册到工厂容器中. 2.进入后findCa ...
- 1、Spring In Action 4th笔记(1)
Spring In Action 4th笔记(1) 2016-12-28 1.Spring是一个框架,致力于减轻JEE的开发,它有4个特点: 1.1 基于POJO(Plain Ordinary Jav ...
- 转 Netflix OSS、Spring Cloud还是Kubernetes? 都要吧!
Netflix OSS.Spring Cloud还是Kubernetes? 都要吧! http://www.infoq.com/cn/articles/netflix-oss-spring-cloud ...
随机推荐
- Python字典的初识、增删改查及嵌套
为什么要有字典? 列表可以存储大量的数据,但数据间的关联型不强 列表的查询速度相对慢 dict:字典,容器型数据类型 数据类型的分类: 可变与不可变 可变(不可哈希)的数据类型: 列表list,字典d ...
- CentOS8 安装
CentOS8 1911 下载 https://mirrors.aliyun.com/centos/8/isos/x86_64/CentOS-8.1.1911-x86_64-dvd1.iso Step ...
- C++学习---栈的构建及操作
一.顺序栈 #include <iostream> using namespace std; #define MAXSIZE 100 //栈的最大容量 typedef struct { i ...
- 学会这三个命令,你就不再是git只会用三板斧的菜鸟了
前言 在之前的文章当中我们介绍了最基本的git add.git commit和git push的用法以及基本原理,还介绍了gitignore文件的设置方法,从而让我们可以使用git add .来添加我 ...
- Flutter - 自定义Dialog弹窗
------------恢复内容开始------------ Flutter - 自定义Dialog弹窗 应用场景:app系统版本升级弹窗,系统退出登录弹窗,首页广告弹窗,消息中心弹窗,删除文件弹窗等 ...
- Ignite、Vertx
Ignite IpFinder 默认采用multicast的ip发现方式 优点: 集群较小时,配置方便 缺点 集群较大100s-1000s时,广播非常耗时,此时建议使用ZooKeeper发现机制(Zo ...
- windows上visual studio 2019配置libtorch
参考链接: https://blog.csdn.net/clx55555/article/details/98172762 https://zhuanlan.zhihu.com/p/68901339 ...
- 平时查询linux服务器与应用版本
###JDK版本###java -version ##Tomcat环境版本###进入到tomcat目录的bin下./version.sh ###服务器###(1)osuname -a 查看releas ...
- py基础知识(一)
python基础知识(一) print('1','2','3',sep=',',end='.') print 函数的用法 print(value,...,sep='',end='\n') 这里的val ...
- U138097 小鱼吃大鱼 埃氏筛
题目描述 小P同学在养殖一种非常凶狠的鱼,而且与其他鱼类不同,这种鱼越大越温顺,反而小鱼最凶残.当两条鱼相遇时, 小鱼会不断撕咬大鱼,每一口都咬下与它自身等重的肉(小鱼保持体重不变),直到大鱼的体重小 ...