ssh之spring的xml简单配置
来源:互联网 发布:新东方网课怎么样 知乎 编辑:程序博客网 时间:2024/06/10 14:54
1.导入相关jar包:
2.随便写一个类:
package com.ltz.service;public class UserService {
public void login(){
System.out.println("login...");
}
}
3.配置applicationContext.xml配置文件(默认放在src目录下):
<?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-3.2.xsd">
<bean name="userService" class="com.ltz.service.UserService"></bean>
</beans>
4.写一个主方法解析applicationContext.xml配置文件:
package com.ltz.test;import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.ltz.service.UserService;
public class UserTest {
public static void main(String[] args) {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
UserService userService = context.getBean("userService", UserService.class);
userService.login();
}
}
注意:出现下列异常时因为需要导入commons-logging-1.1.3.jar这个包。
以上就是spring基本入门配置spring是一个IOC和AOP框架,就是说可以让一个借口代理它的实现类。
0 0
- ssh之spring的xml简单配置
- SSH配置:spring:applicationConfig.xml
- SSH中Spring以及hibernate、Redis的xml配置
- SSH配置之web.xml
- SSH配置之web.xml .
- SSH配置之web.xml .
- SSH配置之web.xml
- SSH配置之web.xml
- ssh整合!Struts.xml、hibernate与spring整合的applicationContext.xml、web.xml文件的配置!
- ssh的简单配置
- ssh整合源码一:配置Spring之applicationContext.xml和web.xml
- Spring AOP简单的配置(注解和xml配置)
- Spring AOP简单的配置(注解和xml配置)
- ssh之struts2xml简单配置
- SSH框架applicationContext.xml简单配置
- SSH与SSM学习之Spring22——Spring事务之xml配置方式管理事务
- ssh项目中,对于spring的bean.xml和web.xml文件的基本配置
- ssh的web.xml配置
- iOS 25个性能优化/内存优化常用方法
- 软件测试的原则
- 状态机
- maven中查看依赖jar的源码和文档
- 阻抗计算公式、polar si9000(教程)
- ssh之spring的xml简单配置
- Word Pattern
- 我就说一句
- HDU 3487 Play with Chain
- 简单的maven项目
- PS学习笔记之色彩模式
- Android代码优化小技巧总结
- 再谈iOS 7的手势滑动返回功能
- 软件测试分类