114 lines
3.1 KiB
Markdown
114 lines
3.1 KiB
Markdown
# 门诊记录接口404问题排查指南
|
||
|
||
## 问题描述
|
||
门诊记录页面报404错误,路径:`/openhis/patient-manage/records/outpatient-record-page`
|
||
|
||
## 修改内容
|
||
|
||
已创建 `OutpatientRecordController.java`:
|
||
- 位置:`openhis-application/src/main/java/com/openhis/web/patientmanage/controller/OutpatientRecordController.java`
|
||
- 请求路径:`/patient-manage/records`
|
||
|
||
## 排查步骤
|
||
|
||
### 1. 清理并重新编译后端项目
|
||
|
||
在命令行执行:
|
||
```bash
|
||
cd e:\his\openhis-server-new
|
||
mvn clean install -DskipTests
|
||
```
|
||
|
||
或者在 IDE 中:
|
||
1. 点击 Maven 中的 `clean` 命令
|
||
2. 等待清理完成
|
||
3. 点击 `install` 或 `compile` 命令
|
||
|
||
### 2. 停止并重启后端服务
|
||
|
||
**重要:必须完全停止当前运行的后端服务,然后重新启动**
|
||
|
||
如果使用 IDE 运行:
|
||
1. 停止当前运行的 Spring Boot 应用
|
||
2. 重新运行 `OpenHisApplication.main()`
|
||
|
||
如果使用命令行运行:
|
||
```bash
|
||
# 停止当前服务 (Ctrl+C)
|
||
cd e:\his\openhis-server-new\openhis-application
|
||
mvn spring-boot:run
|
||
```
|
||
|
||
### 3. 验证Controller是否被加载
|
||
|
||
访问测试接口:
|
||
```
|
||
http://localhost:18080/openhis/patient-manage/records/test
|
||
```
|
||
|
||
如果返回:
|
||
```json
|
||
{
|
||
"code": 200,
|
||
"msg": "操作成功",
|
||
"data": "OutpatientRecordController 工作正常"
|
||
}
|
||
```
|
||
|
||
说明 Controller 已成功加载。
|
||
|
||
### 4. 检查后端启动日志
|
||
|
||
查看启动日志中是否有类似以下内容:
|
||
```
|
||
Mapped "{[/patient-manage/records/test]}" onto ...
|
||
Mapped "{[/patient-manage/records/init]}" onto ...
|
||
Mapped "{[/patient-manage/records/outpatient-record-page]}" onto ...
|
||
Mapped "{[/patient-manage/records/doctor-names]}" onto ...
|
||
```
|
||
|
||
如果没有这些映射日志,说明 Controller 没有被扫描到。
|
||
|
||
### 5. 检查包扫描配置
|
||
|
||
确认 `OpenHisApplication.java` 中:
|
||
```java
|
||
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class},
|
||
scanBasePackages = {"com.core", "com.openhis"})
|
||
```
|
||
|
||
这会扫描 `com.openhis` 包及其子包,包括:
|
||
- `com.openhis.web.patientmanage.controller`
|
||
|
||
### 6. 检查编译输出
|
||
|
||
确认编译后的 class 文件存在于:
|
||
```
|
||
e:\his\openhis-server-new\openhis-application\target\classes\com\openhis\web\patientmanage\controller\OutpatientRecordController.class
|
||
```
|
||
|
||
如果不存在,说明编译有问题。
|
||
|
||
## 常见问题
|
||
|
||
### Q: 重启后还是404
|
||
**A:** 确保完全停止了旧的进程。使用任务管理器检查是否有 `java.exe` 进程在运行,如果有则全部结束。
|
||
|
||
### Q: 编译成功但接口不工作
|
||
**A:** 检查是否访问的是正确的端口和路径:
|
||
- 端口:18080
|
||
- 路径:/openhis/patient-manage/records/outpatient-record-page
|
||
|
||
### Q: 日志中没有映射信息
|
||
**A:** 可能是注解使用错误。已修正为:
|
||
- `@RequiredArgsConstructor` 替代 `@AllArgsConstructor`
|
||
- `private final` 字段直接注入
|
||
|
||
## 验证步骤
|
||
|
||
1. 访问:`http://localhost:18080/openhis/patient-manage/records/test`
|
||
2. 访问:`http://localhost:18080/openhis/patient-manage/records/doctor-names`
|
||
3. 访问:`http://localhost:18080/openhis/patient-manage/records/outpatient-record-page`
|
||
|
||
如果都能正常返回,刷新前端页面即可。
|