diff --git a/springboot-web-req-resp/pom.xml b/springboot-web-req-resp/pom.xml index f2ae0ad..450bab3 100644 --- a/springboot-web-req-resp/pom.xml +++ b/springboot-web-req-resp/pom.xml @@ -47,6 +47,10 @@ dom4j 2.1.3 + + org.springframework.boot + spring-boot-starter-actuator + diff --git a/springboot-web-req-resp/src/main/java/com/inmind/controller/EmpController.java b/springboot-web-req-resp/src/main/java/com/inmind/controller/EmpController.java index 6cee1a7..7e73178 100644 --- a/springboot-web-req-resp/src/main/java/com/inmind/controller/EmpController.java +++ b/springboot-web-req-resp/src/main/java/com/inmind/controller/EmpController.java @@ -11,7 +11,7 @@ import org.springframework.web.bind.annotation.RestController; import java.util.List; -@RestController +@RestController//底层带有@Controller,本身是交给IOC容器管理 public class EmpController { //设置一个员工业务对象 @Autowired//运行时,IOC容器会提供该类型的bean对象,并赋值给该变量----依赖注入 diff --git a/springboot-web-req-resp/src/main/java/com/inmind/dao/impl/EmpDaoImplA.java b/springboot-web-req-resp/src/main/java/com/inmind/dao/impl/EmpDaoImplA.java index f9d9f8e..6b54e7c 100644 --- a/springboot-web-req-resp/src/main/java/com/inmind/dao/impl/EmpDaoImplA.java +++ b/springboot-web-req-resp/src/main/java/com/inmind/dao/impl/EmpDaoImplA.java @@ -3,11 +3,11 @@ package com.inmind.dao.impl; import com.inmind.dao.EmpDao; import com.inmind.pojo.Emp; import com.inmind.utils.XmlParserUtils; -import org.springframework.stereotype.Component; +import org.springframework.stereotype.Repository; import java.util.List; -@Component //将当前类交给IOC容器管理,让它称为IOC容器中的bean对象---IOC控制反转 +@Repository//将当前类交给IOC容器管理,让它称为IOC容器中的bean对象---IOC控制反转 public class EmpDaoImplA implements EmpDao { @Override public List listEmp() { diff --git a/springboot-web-req-resp/src/main/java/com/inmind/service/impl/EmpServiceImplA.java b/springboot-web-req-resp/src/main/java/com/inmind/service/impl/EmpServiceImplA.java index 053983a..2e14be2 100644 --- a/springboot-web-req-resp/src/main/java/com/inmind/service/impl/EmpServiceImplA.java +++ b/springboot-web-req-resp/src/main/java/com/inmind/service/impl/EmpServiceImplA.java @@ -1,11 +1,9 @@ package com.inmind.service.impl; import com.inmind.dao.EmpDao; -import com.inmind.dao.impl.EmpDaoImplA; import com.inmind.pojo.Emp; import com.inmind.service.EmpService; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; import java.util.List; diff --git a/springboot-web-req-resp/src/main/java/com/inmind/service/impl/EmpServiceImplB.java b/springboot-web-req-resp/src/main/java/com/inmind/service/impl/EmpServiceImplB.java index 38e7bbc..3aeb153 100644 --- a/springboot-web-req-resp/src/main/java/com/inmind/service/impl/EmpServiceImplB.java +++ b/springboot-web-req-resp/src/main/java/com/inmind/service/impl/EmpServiceImplB.java @@ -4,11 +4,11 @@ import com.inmind.dao.EmpDao; import com.inmind.pojo.Emp; import com.inmind.service.EmpService; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; import java.util.List; -@Component //将当前类交给IOC容器管理,让它称为IOC容器中的bean对象---IOC控制反转 +@Service //将当前类交给IOC容器管理,让它称为IOC容器中的bean对象---IOC控制反转 public class EmpServiceImplB implements EmpService { //设置一个dao的成员变量 @Autowired//运行时,IOC容器会提供该类型的bean对象,并赋值给该变量----依赖注入