spring实现helloWord
第一步:添加架包
第二步:写一个简单的实列
package com.java.test; /**
* @author nidegui
* @create 2019-06-22 10:58
*/
public class Helloworld { public void say(){
System.out.println("nihao spring");
}
}
第三步:用bean
<?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 id="helloWorld" class="com.java.test.Helloworld"></bean> </beans>
第四步:测试
package com.java.test; import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext; /**
* @author nidegui
* @create 2019-06-22 11:00
*/
public class Test {
public static void main(String[] args) {
ApplicationContext ac = new ClassPathXmlApplicationContext("beans.xml"); //获取bean
Helloworld helloWorld = (Helloworld) ac.getBean("helloWorld"); //获取bean的名字
helloWorld.say();
}
}
spring实现helloWord的更多相关文章
- 1.spring:helloword/注入/CDATA使用/其他Bean/null&级联/p命名空间
新建工程,导入jar,添加spring配置文件(配置文件xxxx.xml)! 1.Helloword实现 Helloword.java public class HelloWord { private ...
- java之spring之helloword
这篇文章主要讲 spring的基础的使用案例 项目整体目录结构: 1.新建一个java项目:spring_helloworld 2.在项目下创建一个lib文件夹,并把一些必须的jar包复制过去 新建l ...
- [原创]java WEB学习笔记96:Spring学习---Spring简介及HelloWord
本博客的目的:①总结自己的学习过程,相当于学习笔记 ②将自己的经验分享给大家,相互学习,互相交流,不可商用 内容难免出现问题,欢迎指正,交流,探讨,可以留言,也可以通过以下方式联系. 本人互联网技术爱 ...
- Spring学习记录(十二)---AOP理解和基于注解配置
Spring核心之二:AOP(Aspect Oriented Programming) --- 面向切面编程,通过预编译方式和运行期动态代理实现程序功能的统一维护的一种技术.AOP是OOP的延续,是软 ...
- Spring学习记录(二)---容器和bean属性配置
下载spring包,在eclipse搭建spring环境. 这步我在eclipse中无法导入包,看网上的: http://sishuok.(和谐)com/forum/blogPost/list/242 ...
- [原创]java WEB学习笔记98:Spring学习---Spring Bean配置及相关细节:如何在配置bean,Spring容器(BeanFactory,ApplicationContext),如何获取bean,属性赋值(属性注入,构造器注入),配置bean细节(字面值,包含特殊字符,引用bean,null值,集合属性list map propert),util 和p 命名空间
本博客的目的:①总结自己的学习过程,相当于学习笔记 ②将自己的经验分享给大家,相互学习,互相交流,不可商用 内容难免出现问题,欢迎指正,交流,探讨,可以留言,也可以通过以下方式联系. 本人互联网技术爱 ...
- spring容器IOC创建对象<二>
问题?spring是如何创建对象的?什么时候创建对象?有几种创建方式?测试对象是单例的还是多例的 ?对象的初始化和销毁? 下面的四大模块IOC的内容了!需要深刻理解 SpringIOC定义:把对象的创 ...
- spring环境的搭建及作用和定义<一>
问题?spring的定义及作用.spring的环境搭建 一.spring的定义及作用 1.spring由Rod Johnson创建的一个开源框架,它是为了解决企业应用开发的复杂性而创建的.框架的主要优 ...
- 【Spring】Spring bean的实例化
Spring实现HelloWord 前提: 1.已经在工程中定义了Spring配置文件beans.xml 2.写好了一个测试类HelloWorld,里面有方法getMessage()用于输出" ...
随机推荐
- nyoj 309
#include<stdio.h> #include<stdlib.h> #define N 1100 int c[N]; int main() { int l,n,i,m,a ...
- 淘宝信海龙 --PHP系统
https://yq.aliyun.com/users/1467229535950742?spm=5176.100239.blogrightarea56002.3.RoToxZ
- sum求和类题目
今天看到这道题目:http://www.cnblogs.com/charlesblc/p/5930311.html 题目地址:https://leetcode.com/problems/split-a ...
- HDU 4540
简单得不能再简单的DP了. #include<iostream> const int inf=1<<30; using namespace std; int map[22][2 ...
- 泛型和面向对象C++
1. 在类内部定义的函数默觉得inline,内联函数应该在头文件里定义,由于其定义对编译器必须是可见的,以便编译器可以在调用点内联展开该函数的代码. 此时,仅有函数原型是不够的. 2.assert 3 ...
- hive学习路线
hive学习路线图:
- springboot配置文件加载位置
springboot 启动会扫描以下位置的application.properties或者application.yml文件作为Spring boot的默认配置文件 –file:./config/ – ...
- 用MJExtension简化MVC
首先引入MJExtension框架 模型 #import <Foundation/Foundation.h> @interface FundsModel : NSObject /** * ...
- HTML文档基础
一.HTML(Hyper Text Markup Language超文本标记语言)是一种用来制作超文本文档的简单标记语言,HTML在正文的文本中编写各种标记,通过Web浏览器进行编译和运行才干正确显示 ...
- Spring+Mybatis之登录功能demo
其实工作之后就没有用过Spring+Mybatis的框架了,因为公司有一个自己开发的框架,讲道理,其实这个与Spring+Mybatis整合很是神似.当然性能上还是比不上Spring+Mybatis所 ...