1. 一般写Spring的文章,会先说一下,IOC容器、DI等概念性的内容。但是由于是个人的笔记,就直入主题。就是要熟悉SpringXML是怎么配的。[https://gitee.com/gao_xi/spring-demo1/tree/master/](https://gitee.com/gao_xi/spring-demo1/tree/master/)

1.开发环境

JDK1.8
Maven3.6
IDEA2019.3

2.搭建步骤

2.1创建工程

image.png

2.2xml文件配置

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  5. <bean id="book" class="com.gao.Book"></bean>
  6. </beans>

2.3代码编写

  1. /**
  2. * @author GaoXi
  3. * @date 2021/8/13 19:31
  4. */
  5. public class Book {
  6. public void sayHello() {
  7. System.out.println("Hello Spring5");
  8. }
  9. }
  10. /**
  11. * @author GaoXi
  12. * @date 2021/8/13 19:33
  13. */
  14. public class Starter {
  15. public static void main(String[] args) {
  16. ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("config.xml");
  17. Book book = applicationContext.getBean("book", Book.class);
  18. book.sayHello();
  19. }
  20. }

3.如何手动下载Spring的相关jar包

image.png
image.png

image.png