spring(一)helloworld
来源:互联网 发布:js截取字符串后四位 编辑:程序博客网 时间:2024/05/17 01:58
Spring概述:
1.轻量级:非侵入性的。对象可以不依赖于Spring的API
2.依赖注入:
3.AOP面向切面编程
4.容器:包含并且管理应用对象的生命周期
5.框架:
6.一站式:可以整合其他框架
Spring模块
HelloWorld:
1.导入jar包:
2.HelloWorld类:
public class HelloWorld {private String name;public String getName() {return name;}public void setName(String name) {this.name = name;}public void Say(){System.out.println("helloworld:"+name);}}
3.applicationContext.xml配置
<?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 --><bean id="HelloWorld" class="com.milan.beans.HelloWorld"><property name="name" value="milan"></property></bean></beans>
4.Main方法中调用HelloWorld的say()方法
public class Main {public static void main(String[] args) {//1.创建IOC容器对象ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");//2.从IOC容器中获取bean实例HelloWorld helloWorld = (HelloWorld) ctx.getBean("HelloWorld");//注:未使用spring的方法//HelloWorld helloWorld = new HelloWorld();//helloWorld.setName("milan");//3.调用hello方法helloWorld.Say();}}
0 0
- spring(一)helloworld
- Spring Boot(一):HelloWorld
- Spring MVC 学习笔记(一):HelloWorld
- Spring MVC 入门指南(一):HelloWorld
- Spring MVC 入门指南(一):HelloWorld
- Spring MVC (一) - HelloWorld
- spring boot 一 HelloWorld
- Spring MVC学习笔记(一)---Spring MVC 的HelloWorld
- Spring学习笔记(一) Spring概述和HelloWorld实例
- (一) spring boot 之 helloworld
- Spring Boot(Web)初探一( 入门【HelloWorld】)
- Spring.net抛砖引玉系列(一)下载安装及HelloWorld
- Spring框架学习(一)——HelloWorld
- spring boot 入门(一)——helloworld
- Spring Boot学习笔记:(一)简介与HelloWorld搭建
- Hibernate HelloWorld(一)
- 【ElasticSearch】Helloworld(一)
- Spring实战(一) —— HelloWorld
- 剑指offer-字符串全排列(有重复值)
- USACO 2015 Feb Bronze 1.Censoring (Bronze) 栈+Hash
- Hey,Tomorrow——2016年度 总结
- thinkcmf上线处理总结
- C++sort函数的用法
- spring(一)helloworld
- 修改Mysql中root账号的空密码方法
- DBA解题集:将回档时间从 14小时降低到 10分钟的方法
- Shader特效——“Simple RayTrace”的实现 【GLSL】
- APP设计师必知:用户体验十大原则!,互联网的一些事
- WinEdt 和 Sumatra 双向关联设置
- 为什么要用EL+JSP标签而不用JSP脚本
- win7 开发相关 软件装机
- Apache HttpClient