在使用Spring框架时:
1.1:(spring.jar和文件上传的jar.包和json.jar包)
aopalliance-1.0.jar
aspectjweaver-1.8.2.jar
commons-fileupload-1.3.1.jar
commons-io-1.3.2.jar
commons-lang-2.6.jar
commons-logging-1.1.3.jar
fastjson-1.2.7.jar
jackson-annotations-2.2.1.jar
jackson-core-2.2.1.jar
jackson-core-asl-1.8.8.jar
jackson-databind-2.2.1.jar
jackson-mapper-asl-1.8.8.jar
jackson-module-jaxb-annotations-2.2.1.jar
json.jar
jstl-1.2.jar
spring-aop-4.1.0.RELEASE.jar
spring-aspects-4.1.0.RELEASE.jar
spring-beans-4.1.0.RELEASE.jar
spring-context-4.1.0.RELEASE.jar
spring-context-support-4.1.0.RELEASE.jar
spring-core-4.1.0.RELEASE.jar
spring-expression-4.1.0.RELEASE.jar
spring-instrument-4.1.0.RELEASE.jar
spring-instrument-tomcat-4.1.0.RELEASE.jar
spring-jdbc-4.1.0.RELEASE.jar
spring-jms-4.1.0.RELEASE.jar
spring-orm-4.1.0.RELEASE.jar
spring-oxm-4.1.0.RELEASE.jar
spring-test-4.1.0.RELEASE.jar
spring-tx-4.1.0.RELEASE.jar
spring-web-4.1.0.RELEASE.jar
spring-webmvc-4.1.0.RELEASE.jar
spring-webmvc-portlet-4.1.0.RELEASE.jar、
1.2:写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"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.1.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.1.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.1.xsd">
</beans>
1.2.1:spring功能1:实例化所有类 (自定义类)
1.2.1_1: 用<bean>的方式;
在javabean中读spring.xml配置文件
1.2.1_2:用注解的方式:(注解不能用第三方类,除非有源码,如:实例化students集合)
<!-- spring功能1.2:实例化第三方类
java.util.List students = new java.util.ArrayList
-->
<bean name="students" class="java.util.ArrayList"></bean>
base-package="包名“,它是扫描包名下的类;
(可以是指定具体的包;也可以是:con.lanou.fuxi.* 以con.lanou.fuxi开头的所有的包下的类)
默认是类名(首字母小写)bookinfo实例化对象;
指定实例对象:相当于 BooinfoServce bookinfoService = new BookinfoServiceImpl();
(@Component :是所有类都适用;@Service:只适用业务层;@Controller:控制层 @Repository:持久层 )
小结:spring功能1:实例化:
1.1:<bean>的方式 name="实化的对象名" class="类的全名,即包名加类名";
在Javabean中要先读取spring.xml配置文件;
1.2:注解的方式:用<context:component-scan >标签开启自动扫描;
类首加注解,接口除外;