引入 jar包
配置文件 applicationContext.xml (主配置文件中,引入了子配置文件,不影响)
Bean对象 Family ,User
测试Demo SpringDemo
可能产生的异常
spring | org.springframework.beans-3.0.5.RELEASE.jar | 必要 |
org.springframework.core-3.0.5.RELEASE.jar | 必要 | |
org.springframework.aop-3.0.5.RELEASE.jar | 不必要 | |
org.springframework.context-3.0.5.RELEASE.jar | 必要 | |
org.springframework.transaction-3.0.5.RELEASE.jar | 不必要 | |
org.springframework.test-3.0.5.RELEASE.jar | 不必要 | |
org.springframework.expression-3.0.5.RELEASE.jar | 必要 | |
org.springframework.orm-3.0.5.RELEASE.jar | 不必要 | |
org.springframework.jdbc-3.0.5.RELEASE.jar | 不必要 | |
org.springframework.context.support-3.0.5.RELEASE.jar | ||
org.springframework.asm-3.0.5.RELEASE.jar | 必要 |
aopalliance.jar (与hibernate结合时加入)
applicationContext配置文件
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:jpa="http://www.springframework.org/schema/data/jpa" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"> <import resource="/spring_xml/applicationContext_default.xml"/> </beans>
子配置spring配置文件 spring_default.xml
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:jpa="http://www.springframework.org/schema/data/jpa" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa-1.0.xsd " xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"> <context:component-scan base-package="com.web.wp"/> <bean id="user" class="com.web.wp.domain.User"/> </beans>
Bean对象
import org.springframework.stereotype.Component; /** * 家庭Bean原型 * */ @Component public class Family { private Long id; private String address; private int number; /**用string对象替换list*/ private String userids;
import org.springframework.stereotype.Component; /** * 家庭Bean原型 * */ @Component public class Family { private Long id; private String address; private int number; /**用string对象替换list*/ private String userids;
测试SpringDemo
package com.web.wp.spring; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import com.web.wp.domain.Family; import com.web.wp.domain.User; /** * 独立测试spring框架 * */ public class SpringDemo { /** * 获取applicationCOntext * 分辨 ClassPathXmlApplicationContext和FileSystemXmlApplicationContex区别 * classpath:前缀是不需要的,默认就是指项目的classpath路径下面; * 默认表示的是两种: * 1.没有盘符的是项目工作路径,即项目的根目录; * 2.有盘符表示的是文件绝对路径. * */ public static void main(String[] args) { ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml"); System.out.println(ac!=null); Family fa=ac.getBean(Family.class); System.out.println(fa!=null); User us=ac.getBean(User.class); System.out.println(us!=null); } }
可能产生的异常
Caused by: java.lang.ClassNotFoundException: org.springframework.expression.PropertyAccessor 结果 缺少引入 org.springframework.expression-3.0.5.RELEASE.jar
相关推荐
(1) spring-core.jar 这个jar文件包含Spring框架基本的核心工具类,Spring其它组件要都要使用到这个包里的类,是其它组件的基本核心,当然你也可以在自己的应用系统中使用这些工具类。 (2) spring-beans.jar 这个...
这个jar文件包含Spring框架基本的核心工具类,Spring其它组件要都要使用到这个包里的类,是其它组件的基本核心,当然你也可以在自己的应用系统中使用这些工具类。 (2) spring-beans.jar 这个jar文件是所有应用都要...
当然,如果你的应用使用了独立的MVC 框架,则无需这个JAR 文件里的任何类。 外部依赖spring-web, (spring-support,Tiles,iText,POI)。 spring-aspects.jar :提供对AspectJ的支持,以便可以方便的将面向方面的...
这个jar文件包含Spring框架基本的核心工具类,Spring其它组件要都要使用到这个包里的类,是其它组件的基本核心,当然你也可以在自己的应用系统中使用这些工具类。 (2) spring-beans.jar 这个jar文件是所有应用都要...
Spring框架:引领企业级应用开发的强大引擎 Spring框架,作为Java企业级应用开发的领军者,以其独特的优势,为开发者提供了高效、灵活且易于维护的解决方案。它不仅仅是一个简单的框架,更是一套完整的开发理念和...
系统的学习Spring框架中各个部分,掌握Spring中一些高级特性的使用。 l Spring IoC n 设计模式-工厂模式 n 基础应用-入门案例 n 基础应用-常用注解使用场景介绍及入门 n 高级特性-自定义BeanNameGenerator n 高级...
包含Web应用开发时,用到Spring框架时所需的核心类,包括自动载入WebApplicationContext特性的类、Struts与JSF集成类、文件上传的支持类、Filter类和大量工具辅助类。 18. spring-webmvc-4.1.1.RELEASE.jar 包含...
Java Spring框架由多个模块组成,每个模块都提供了不同的功能,可以根据项目需求选择使用。其中最核心的模块是Spring Core,它提供了IoC(控制反转)和DI(依赖注入)的功能,使得对象之间的依赖关系由框架来管理,...
Spring不会给你的工程添加对其他的框架依赖。Spring也许称得上是个一站式解决方案,提供了一个典型应用所需要的大部分基础架构。它还涉及到了其他framework没有考虑到的内容。 尽管它仅仅是一个从2003年2月才开始...
书中第一部分展示了Spring框架的两个核心特性:依赖注入和面向切面编程。第二部分以第一部分介绍的DI和AOP特性为基础,叙述了如何将这两个概念应用到应用程序的数据和业务层中。第三部分介绍了Spring构建 Web应用...
书中第一部分展示了Spring框架的两个核心特性:依赖注入和面向切面编程。第二部分以第一部分介绍的DI和AOP特性为基础,叙述了如何将这两个概念应用到应用程序的数据和业务层中。第三部分介绍了Spring构建 Web应用...
16.7.3 使用Spring RestTemplate测试 16.7.4 使用Selenium测试 16.8 小结 第17章 实战案例开发 17.1 论坛案例概述 17.1.1 论坛整体功能结构 17.1.2 论坛用例描述 17.1.3 主要功能流程描述 17.2 系统设计 17.2.1 技术...
Spring 不需要你的项目再依赖于另一个框架。Spring 也许能称得上是一个“一站式”商店, 提供了大多数传统应用所需要的基础结构。它还提供了别的框架没有涉及到的东西。 作为一个从2003 年2 月开始的开源项目,...
正如我将在下一个示例中演示的那样,Spring 框架使用 JavaBean 属性和配置数据来指出必须设置的依赖关系。 BeanFactory 接口 因为 org.springframework.beans.factory.BeanFactory 是一个简单接口,所以可以针对...
16.7.3 使用Spring RestTemplate测试 16.7.4 使用Selenium测试 16.8 小结 第17章 实战案例开发 17.1 论坛案例概述 17.1.1 论坛整体功能结构 17.1.2 论坛用例描述 17.1.3 主要功能流程描述 17.2 系统设计 17.2.1 技术...
基于SSM框架的系统通常指的是利用Spring、Spring MVC和MyBatis这三个Java开发框架构建的应用程序。SSM是这三个框架的首字母缩写,它们合作提供了一个强大的技术栈,用于开发企业级的Web应用程序。以下是每个框架的...
依赖注入(DI):当编写一个复杂的Java应用程序时,应用程序类应该尽可能的独立于其他的Java类来增加这些类可重用可能性,当进行单元测试时,可以使他们独立于其他类进行测试。依赖注入(或者有时被称为配线)有助于...
Spring Boot是一个用于快速构建基于Spring框架的应用程序的开源框架。它简化了Spring应用程序的初始配置和开发过程,提供了一个约定大于配置的开发模式,使得开发人员可以更专注于业务逻辑的实现。 Spring Boot的...
其次,我们使用Spring,而我使用了依赖注入。 但是依赖注入的挑战性问题是什么。 假设您已经为一个实现准备好两个实现,那么您将如何选择实现? 我将解释几种方法,但同时还将演示如何通过外部配置选择实现,以便...
Spring TestContext Framework集成测试 SpringMVC基础 Spring MVC概述 SpringMVC项目快速搭建 构建Maven项目 日志配置 演示页面 Spring MVC配置 Web配置 简单控制器 运行 Spring MVC...