原文链接:XML-Based Injection in Spring
1. Introduction 概述
In this basic tutorial, we’ll learn how to do simple XML-based bean configuration with the Spring Framework.
这里,一起学习如何在Spring框架中使用XML文件进行bean对象配置吧
2. Overview 回顾一下
Let's start by adding Spring's library dependency in the pom.xml:
首先在pom.xml文件中添加Spring上下文的依赖
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.1.4.RELEASE</version>
</dependency>
3. Dependency Injection – an Overview 复习下依赖注入
Dependency injection is a technique whereby dependencies of an object are supplied by external containers.
依赖注入是一种技术理念,通过一个外部容器来提供某个对象所需要的所有依赖。
Let's say we've got an application class that depends on a service that actually handles the business logic:
让我们来假设,已经有一个程序类,它依赖了一个service来真正的处理业务逻辑,如下:
public class IndexApp {
private IService service;
// standard constructors/getters/setters
}
<