# 值错误: 具有相同路径的路由已存在。

- **ID:** `python/starlette-route-mount-conflict`
- **领域:** python
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

在Starlette应用中重复注册相同路径的路由，导致冲突。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.x | active | — | — |

## 解决方案

1. **删除旧路由再注册新路由** (85% 成功率)
   ```
   from starlette.routing import Route; routes = [route for route in app.routes if route.path != '/existing']; routes.append(Route('/existing', endpoint=new_handler)); app.router.routes = routes
   ```
2. **使用不同的路径或添加版本前缀** (95% 成功率)
   ```
   app.add_route('/v2/existing', new_handler)
   ```

## 无效尝试

- **尝试覆盖路由而不删除旧路由** — 框架不允许重复注册。 (90% 失败率)
- **使用不同的HTTP方法但路径相同** — Starlette允许相同路径不同方法，但若方法也相同则冲突。 (50% 失败率)
