《Spring》篇章整体栏目
—————————————————————————————
【第一章】spring 概念与体系结构
【第二章】spring IoC 的工作原理
【第三章】spring IOC与Bean环境搭建与应用
【第四章】spring bean定义
【第五章】Spring 集合注入、作用域
【第六章】Spring 自动装配
【第七章】spring AOP
【第八章】Spring 集成JdbcTemplate
【第九章】Spring数据库事务管理
【第十章】Spring 集成Redis
【第十一章】Spring实战之打造新闻系统后端接口
—————————————————————————————
目录
—————————————————————————————
1、手动导入Lib包搭建环境
1.1、下载Apache Common Logging API
https://commons.apache.org/proper/commons-logging/download_logging.cgi
1.2、下载spring
https://repo.spring.io/ui/native/release/org/springframework/spring/5.3.13/
名称 | 作用 |
---|---|
docs | 包含 Spring 的 API 文档和开发规范 |
libs | 包含开发需要的 jar 包和源码包 |
schema | 包含开发所需要的 schema 文件,在这些文件中定义了 Spring 相关配置文件的约束 |
名称 | 作用 |
---|---|
spring-core-x.x.xx.jar | 包含 Spring 框架基本的核心工具类,Spring 其他组件都要用到这个包中的类,是其他组件的基本核心。 |
spring-beans-x.x.xx.jar | 所有应用都要用到的,它包含访问配置文件、创建和管理 Bean 以及进行 Inversion of Control(IoC)或者 Dependency Injection(DI)操作相关的所有类。 |
spring-context-x.x.xx.jar | Spring 提供在基础 IoC 功能上的扩展服务,此外还提供许多企业级服务的支持,如邮件服务、任务调度、JNDI 定位、EJB 集成、远程访问、缓存以及各种视图层框架的封装等。 |
spring-expression-x.x.xx.jar | 定义了 Spring 的表达式语言。需要注意的是,在使用 Spring 开发时,除了 Spring 自带的 JAR 包以外,还需要一个第三方 JAR 包 commons.logging 处理日志信息。 |
2、Hello world
2.1、导入依赖包
2.2、定义bean类:HelloWorld.java
2.3、定义Spring bean加载类
2.4、定义配置文件bean.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-3.0.xsd">
<bean id="helloWorld" class="com.xxx.spring.bean.HelloWorld">
<property name="message" value="Hello world"/>
</bean>
</beans>