# java-project-health **Repository Path**: ifredom/java-project-health ## Basic Information - **Project Name**: java-project-health - **Description**: 医疗项目实践 - **Primary Language**: Java - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-05-12 - **Last Updated**: 2022-05-13 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # [传智健康全栈项目](https://www.bilibili.com/video/BV1Bo4y117zV?p=9&spm_id_from=pageDriver) - spring 项目 - mybatis - dubbo - ZooKeeper 服务注册中心 环境:java11 ## 项目结构 - health_parent:父工程,打包方式为pom,统一锁定依赖的版本,同时聚合其他子模块便于统一执行 maven命令 - health_common:通用模块,打包方式为jar,存放项目中使用到的一些工具类、实体类、返回结果和 常量类 - health_interface:打包方式为jar,存放服务接口 - health_service_provider:Dubbo服务模块,打包方式为war,存放服务实现类、Dao接口、Mapper 映射文件等,作为服务提供方,需要部署到tomcat运行 - health_backend:传智健康管理后台,打包方式为war,作为Dubbo服务消费方,存放Controller、 HTML页面、js、css、spring配置文件等,需要部署到tomcat运行 - health_mobile:移动端前台,打包方式为war,作为Dubbo服务消费方,存放Controller、HTML页 面、js、css、spring配置文件等,需要部署到tomcat运行 ## 启动方式 启动两个服务+zookeeper - health_backend ---> 插件 tomcat7指令 ---> `tomcat7:run` D启动: - health_service_provider ---> 插件 tomcat7指令 ---> `tomcat7:run` D启动: - 本地开启 zoopeeker服务 : D:\Asoftware\apache-zookeeper-3.6.3-bin\apache-zookeeper-3.6.3-bin\bin\zkServer.cmd > [访问地址:http://localhost:82/pages/main.html](http://localhost:82/pages/main.html) > > 前端页面:预约管理-检查项管理 ### 拓展阅读 [ZooKeeper与 Eureka异同](https://juejin.cn/post/6857660242818891783) [Dubbo是什么?](https://blog.csdn.net/ichsonx/article/details/39008519) [windows下安装以及配置ZooKeeper](https://blog.csdn.net/weixin_45974176/article/details/123079508) ### 警告异常 1. Java版本为11时,执行 maven install 会出现非法反射 警告。可以忽略 ```bash WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by com.thoughtworks.xstream.core.util.Fields (file:/C:/Users/dell/.m2/repository/com/thoughtworks/xstream/xstream/1.3.1/xstream-1.3.1.jar) to field java.util.Properties.defaults WARNING: Please consider reporting this to the maintainers of com.thoughtworks.xstream.core.util.Fields WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release ``` 2. [`CheckItemService` 空指针,服务发现错误. 因为 注解@Reference引用的包错了,应该重新引用dubbo提供的注解类](https://blog.csdn.net/qq_38853759/article/details/114763579) ```java package com.itheima.controller; import com.alibaba.dubbo.config.annotation.Reference; import com.itheima.constant.MessageConstant; import com.itheima.pojo.CheckItem; import com.itheima.service.CheckItemService; import com.itheima.utils.Result; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping("/checkitem") public class CheckItemController { @Reference private CheckItemService checkItemService; @RequestMapping("/add") public Result addItem(@RequestBody CheckItem checkItem) { try { checkItemService.add(checkItem); } catch (Exception e) { e.printStackTrace(); return new Result(false, MessageConstant.ADD_CHECKITEM_FAIL); } return new Result(false, MessageConstant.ADD_CHECKITEM_SUCCESS); } } ``` 3. DAO 找不到 查看 dao接口名与 Mapper 文件的名称一致,xml文件中的 namespace 与 paramtype 是否一样 ```bash [DUBBO] Got unchecked and undeclared exception which called by 192.168.2.29. service: com.itheima.service.CheckItemService, method: add, exception: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.itheima.dao.CheckItemDao.add, dubbo version: 2.6.0, current host: 127.0.0.1 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.itheima.dao.CheckItemDao.add ```