2021-03-28

Spring框架包
下载地址:Spring 4.3.6版本的框架压缩包
如下图所示
2021-03-28

除自带的JAR包外,Spring的核心容器还需要以来commons.logging的JAR包。下载地址:第三方依赖包

按如下图所示下载2021-03-28
Spring核心容器
1.BeanFactory

Spring 的入门程序:
第一步:创建Dnamic Web project
2021-03-28
以下附上代码,参考理解

UserDao.java

package com.hncj.dao;

public interface UserDao {
	public void say();
}

UserDaoImpl.java

package com.hncj.dao;

public class UserDaoImpl implements UserDao{
	public void say() {
		System.out.println("userDao say hello word!");
	}
}

application.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-4.3.xsd">
	<bean id="userDao" class="com.hncj.dao.UserDaoImpl" />
	</beans>

TextIoc.java

package com.hncj.dao;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class TestIoc {
	public static void main(String[] args) {
		ApplicationContext applicationContext = new ClassPathXmlApplicationContext("application.xml");
		UserDao userDao = (UserDao) applicationContext.getBean("userDao");
		userDao.say();
	}
}

上一篇:对Mybatis框架的学习


下一篇:微信支付测试账号申请