Spring第一天
第一节:Spring简介
Spring作者:Rod Johnson;
官方网站:http://spring.io/
最新开发包及文档下载地址:https://repo.spring.io/ui/native/libs-release-local/org/springframework/spring/4.3.29.RELEASE/
什么是spring
Spring是一个开源框架,是于2003年兴起的一个轻量级的java开发框架,由rod Johnson创建,简单来说spring是一个分层的JavaEE/SE full-stack(一站式)轻量级开源框架。
优势之一是其分层架构,分层架构允许使用者选择使用哪一种组件,同时为J2EE应用程序开发提供集成的框架。Spring使用基本的JavaBean完成以前EJB(企业级JavaBean)完成的事情。可用于服务器端的开发,从简单性、可测试性、松耦合性而言,任何应用程序开发都可以从中受益。Spring的核心是控制反转(IoC)和面向切面(AOP)。简单来说,spring是一个分层的JavaEE/SE full-stack(一站式)轻量级开源框架。
第二节:Spring的jar包
第三节:配置spring.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 id="helloWorld" class="com.capchem.HelloWorld"></bean> </beans>
第四节:通过Spring生成实例对象
package com.capchem.test; import org.junit.Before; import org.junit.Test; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import com.capchem.HelloWorld; public class Test01 { private ApplicationContext ac; @Before public void getAC(){ ac = new ClassPathXmlApplicationContext("beans.xml"); } @Test public void test01(){ HelloWorld helloworld = (HelloWorld) ac.getBean("helloWorld"); helloworld.say(); } }
https://www.cnblogs.com/qlqwjy/p/7544958.html

浙公网安备 33010602011771号