diff --git a/user-client/pom.xml b/user-client/pom.xml
index 66f0d53..bfc647c 100644
--- a/user-client/pom.xml
+++ b/user-client/pom.xml
@@ -6,4 +6,5 @@
0.0.1-SNAPSHOT
user-client
+ 0.0.2-SNAPSHOT
\ No newline at end of file
diff --git a/user-client/src/main/java/com/hp/user/client/service/AreaService.java b/user-client/src/main/java/com/hp/user/client/service/UserAreaService.java
similarity index 59%
rename from user-client/src/main/java/com/hp/user/client/service/AreaService.java
rename to user-client/src/main/java/com/hp/user/client/service/UserAreaService.java
index e925c72..a66de4d 100644
--- a/user-client/src/main/java/com/hp/user/client/service/AreaService.java
+++ b/user-client/src/main/java/com/hp/user/client/service/UserAreaService.java
@@ -11,7 +11,9 @@ import java.util.List;
*
* @author 王怡静
* @since 2020-11-20
+ *
+ * 使用AreaServcie来命名在自动注入bean的时候会保存,不知道和那个类同名了
*/
-public interface AreaService{
+public interface UserAreaService{
public List getAllArea();
}
diff --git a/user-service/pom.xml b/user-service/pom.xml
index 55fd9b3..0be5fdf 100644
--- a/user-service/pom.xml
+++ b/user-service/pom.xml
@@ -6,6 +6,7 @@
0.0.1-SNAPSHOT
user-service
+ jar
@@ -17,12 +18,16 @@
org.mybatis.spring.boot
mybatis-spring-boot-starter
+
+ org.springframework
+ spring-beans
+
com.hp
user-client
- 0.0.1-SNAPSHOT
+ 0.0.2-SNAPSHOT
com.hp
@@ -47,6 +52,10 @@
org.springframework.boot
spring-boot-starter
+
+ org.springframework
+ spring-beans
+
@@ -84,21 +93,39 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-shade-plugin
+ 2.4.1
+
+
+ package
+
+ shade
+
+
+
+
+
+ META-INF/spring.handlers
+
+
+ META-INF/spring.schemas
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/user-service/src/main/java/com/hp/user/service/controller/AreaController.java b/user-service/src/main/java/com/hp/user/service/controller/AreaController.java
index 44f9328..013fa98 100644
--- a/user-service/src/main/java/com/hp/user/service/controller/AreaController.java
+++ b/user-service/src/main/java/com/hp/user/service/controller/AreaController.java
@@ -1,9 +1,8 @@
package com.hp.user.service.controller;
import com.hp.user.client.entity.AreaVO;
-import com.hp.user.client.service.AreaService;
-import com.hp.user.service.dao.AreaMapper;
-import com.hp.user.service.entity.Area;
+import com.hp.user.client.service.UserAreaService;
+
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -15,7 +14,7 @@ import java.util.List;
public class AreaController {
@Autowired
- private AreaService areaService;
+ private UserAreaService areaService;
/**
* 查询所有地区
diff --git a/user-service/src/main/java/com/hp/user/service/controller/TestController.java b/user-service/src/main/java/com/hp/user/service/controller/TestController.java
deleted file mode 100644
index 256e76a..0000000
--- a/user-service/src/main/java/com/hp/user/service/controller/TestController.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.hp.user.service.controller;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import com.hp.user.service.TestService;
-
-/*
-@RestController
-public class TestController {
- @Autowired
- private TestService userService;
-
- @RequestMapping("getUser/{id}")
- public String GetUser(@PathVariable int id){
- return userService.Sel(id).getName().toString();
- }
-
-}
-*/
-
diff --git a/user-service/src/main/java/com/hp/user/service/impl/AreaServiceImpl.java b/user-service/src/main/java/com/hp/user/service/impl/AreaServiceImpl.java
index fc270d2..a941fef 100644
--- a/user-service/src/main/java/com/hp/user/service/impl/AreaServiceImpl.java
+++ b/user-service/src/main/java/com/hp/user/service/impl/AreaServiceImpl.java
@@ -1,9 +1,8 @@
package com.hp.user.service.impl;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hp.user.client.entity.AreaVO;
+import com.hp.user.client.service.UserAreaService;
import com.hp.user.service.entity.Area;
-import com.hp.user.client.service.AreaService;
import com.hp.user.service.dao.AreaMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -20,8 +19,8 @@ import java.util.List;
* @author 王怡静
* @since 2020-11-20
*/
-@Service
-public class AreaServiceImpl implements AreaService {
+@Service("area")
+public class AreaServiceImpl implements UserAreaService {
@Autowired
private AreaMapper areaMapper;
@Override
diff --git a/user-service/src/test/java/com/hp/user/service/ControllerTest.java b/user-service/src/test/java/com/hp/user/service/ControllerTest.java
new file mode 100644
index 0000000..78c8354
--- /dev/null
+++ b/user-service/src/test/java/com/hp/user/service/ControllerTest.java
@@ -0,0 +1,30 @@
+package com.hp.user.service;
+
+import org.junit.Test;
+
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.hp.user.client.entity.AreaVO;
+import com.hp.user.client.service.UserAreaService;
+
+import java.util.List;
+
+@SpringBootTest
+@RunWith(SpringRunner.class)
+//这个class的路径要注意,要和需要注入的一些bean文件的最外层,不如会出现文件扫描不到的情况
+//从测试结果来看这边回去找服务的启动类UserServiceApplaction
+public class ControllerTest {
+
+ @Autowired
+ private UserAreaService areaService;
+
+
+ @Test
+ public void testQueryAllArea() {
+ List users = areaService.getAllArea();
+ users.forEach(System.out::println);
+ }
+}
diff --git a/user-service/src/test/java/test/ControllerTest.java b/user-service/src/test/java/test/ControllerTest.java
deleted file mode 100644
index 0832c7c..0000000
--- a/user-service/src/test/java/test/ControllerTest.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package test;
-
-import com.alibaba.nacos.spring.context.annotation.config.NacosPropertySource;
-import com.hp.user.client.entity.AreaVO;
-import com.hp.user.service.controller.AreaController;
-
-import org.junit.Test;
-
-import org.junit.runner.RunWith;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringRunner;
-
-import javax.annotation.Resource;
-import java.util.List;
-@NacosPropertySource(dataId = "userdatasource", autoRefreshed = true)
-@RunWith(SpringRunner.class)
-@SpringBootTest
-public class ControllerTest {
- @Resource
- private AreaController areaController;
-
-
- @Test
- public void testQueryAllArea() {
- List users = areaController.queryAllArea();
- users.forEach(System.out::println);
- }
-}