spring 学习基础jar包
spring 学习
最近在学习spring框架,感觉到了sping框架在开发中的方便性,就用博客来当笔记吧。
首先要去spring官网下载jar包
[spring官网链接](https://spring.io/)
[spring相关 jar包下载教程链接] (https://jingyan.baidu.com/article/455a99505b399da16627783b.html)
然后还有些spring jar包中没有的东西,这时就要去maven下载。在maven官网搜索需要的jar包然后把代码复制到maven项目的pom.xml配置文件里面,然后maven项目就会帮你下载到本地maven库中,spring项目要用直接去maven库复制就行了
jar包导入
第一天,学了ioc(控制反转)DI(依赖注入)需要的jar包不多只有五个,四个核心,一个依赖
效果是这样的
然后就可以开始写配置文件了
配置文件一般命名为applicationContext.xml
bean的装配基于注解的配置文件
<?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:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<!-- schema命名空间
1.命名空间声明
默认:xmlns="" <标签名>
显示:xmlns:别名="" <别名:标签名> -》<context:...>
2.确定schema xsd位置
xsi:schemaLocation="名称 位置 名称2 位置2"
-->
<!-- 创建Service实例 -->
<!--
<bean id="userService" class="com.itheima.spring_annotation.a_ioc.UserServiceimpl"></bean>
-->
<!-- 组件扫描, 扫描含有注解的类 -->
<context:component-scan base-package="com.itheima.spring_annotation.a_ioc"></context:component-scan>
</beans>