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/UserAreaService.java b/user-client/src/main/java/com/hp/user/client/service/UserAreaService.java new file mode 100644 index 0000000..a66de4d --- /dev/null +++ b/user-client/src/main/java/com/hp/user/client/service/UserAreaService.java @@ -0,0 +1,19 @@ +package com.hp.user.client.service; + +import com.hp.user.client.entity.AreaVO; + +import java.util.List; + +/** + *

+ * 区域表 服务类 + *

+ * + * @author 王怡静 + * @since 2020-11-20 + * + * 使用AreaServcie来命名在自动注入bean的时候会保存,不知道和那个类同名了 + */ +public interface UserAreaService{ + public List getAllArea(); +} diff --git a/user-service/pom.xml b/user-service/pom.xml index 1506b38..d7ba613 100644 --- a/user-service/pom.xml +++ b/user-service/pom.xml @@ -6,6 +6,7 @@ 0.0.1-SNAPSHOT user-service + jar @@ -48,13 +49,15 @@ spring-boot-starter-json org.springframework.boot + org.springframework + spring-beans com.hp user-client - 0.0.1-SNAPSHOT + 0.0.2-SNAPSHOT com.hp @@ -101,6 +104,10 @@ org.springframework.boot spring-boot-starter + + org.springframework + spring-beans + @@ -152,21 +159,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 46fec14..f542a03 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,11 +1,11 @@ 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 io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import com.hp.user.client.service.UserAreaService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; @@ -20,7 +20,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); - } -} diff --git a/user-service/user-service.iml b/user-service/user-service.iml index 4c07496..d59e558 100644 --- a/user-service/user-service.iml +++ b/user-service/user-service.iml @@ -17,8 +17,8 @@ - - + + @@ -27,15 +27,37 @@ - - - + + + + + + + + + + + + + + + + + + + + + + + + + @@ -43,7 +65,6 @@ - @@ -51,37 +72,27 @@ - - + + + + + + - - + - - - - - - - - - - - - - - + @@ -89,21 +100,19 @@ - - - - + + @@ -114,7 +123,60 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file