# spring-factories-template **Repository Path**: spring-template/spring-factories-template ## Basic Information - **Project Name**: spring-factories-template - **Description**: No description available - **Primary Language**: Java - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-07-10 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # spring-factories-template ### 项目目标 引入不同的Jar包,spring注入不同的接口实现 ### 项目说明 * service-api:创建了一个Person接口 * service-impl1:WhitePerson实现了Person接口 * service-impl2:BlackPerson实现了Person接口 * spring-boot-demo:具体使用 ### spring-boot-demo说明 代码很简单给`Person`接口注入一个实现,当用户访问`hello()`时,调用`Person`的`sayHello`方法 ``` @RestController public class UserController { @Autowired private Person person; @GetMapping("hello") public String hello(){ return person.sayHello("张三"); } } ``` Person有两个实现类`WhitePerson`和`BlackPerson`,可通过修改`pom.xml`中的包引入,来切换实现方法 ``` com.v5ba service-impl1 0.0.1-SNAPSHOT ```