Sping Ai 接入 Mysql MCP 智能查询数据


Sping Ai 接入 Mysql MCP 智能查询数据
Mysql MCP 主要提供SQL语句查询数据库的能力,execute_query :支持select查询、show展示、describe描述;get_table_info:获取数据表的详细结构信息;list_tables:列出数据库中的所有数据表。
LLM + Mysql MCP 可以实现智能查询业务数据,达到减少开发成本,快速应对多变的需求的效果,让复杂点击操作交互方式变成聊天方式,更智能化

应用场景

我想知道用户的基本信息,和角色权限信息。

Sping Ai 接入 Mysql MCP 智能查询数据
Sping Ai 接入 Mysql MCP 智能查询数据

 

快速开始

  • • maven 依赖
<dependency>
    <groupId>org.springframework.ai</groupId>
    <artifactId>spring-ai-starter-mcp-client</artifactId>
    <version>1.0.0</version>
</dependency>
 <dependency>
     <groupId>org.springframework.ai</groupId>
     <artifactId>spring-ai-starter-model-openai</artifactId>
     <version>1.0.0</version>
 </dependency>
  • • 配置文件
spring.ai.openai.base-url=https://dashscope.aliyuncs.com/compatible-mode/
spring.ai.openai.chat.options.model=qwen-max
spring.ai.openai.api-key=${OPEN_API_KEY}
spring.ai.mcp.client.stdio.servers-configuration=classpath:/mcp-servers-config.json
  • • Excel mcp :mcp-servers-config.json
{
  "mcpServers":{
    "mysql":{
      "command":"npx",
      "args":["mysql-mcp-server"],
      "env":{
        "MYSQL_HOST":"127.0.0.1",
        "MYSQL_PORT":"3306",
        "MYSQL_USER":"root",
        "MYSQL_PASSWORD":"123456",
        "MYSQL_DB":"ruoyi"
      }
    }
}
}

 

前沿技术新闻资讯模型微调

Reasoning模型蒸馏实践:用大模型提升小模型能力

2026-5-3 23:14:00

个人提效企业落地新闻资讯

一句话,生成一个 Skill:我在 PAI 里看到 AI 使用方式的拐点

2026-5-3 23:22:44

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
购物车
优惠劵
搜索