当前位置: 首页 > wzjs >正文

分享几个x站好用的关键词开发手机app游戏公司

分享几个x站好用的关键词,开发手机app游戏公司,湖南网站开发公司电话,wordpress如何通过后台增加主菜单作者简介:你好,我是影子,Spring Ai Alibaba开源社区 Committer,持续分享Spring Ai Alibaba最新进展 业界各类AI工程相关的方案 最近有断时间没更了,熟悉我的朋友知道我刚结束完毕业旅行,最近也因为入职&a…

作者简介:你好,我是影子,Spring Ai Alibaba开源社区 Committer,持续分享Spring Ai Alibaba最新进展 + 业界各类AI工程相关的方案

  • 最近有断时间没更了,熟悉我的朋友知道我刚结束完毕业旅行,最近也因为入职,参与公司为期一周的文化相关的培训(培训的东西真是太赞了,每一条都直击高效生活的本质,受益非浅,主动积极、双赢思维,个人成长->公众成长等等),实在抽不出时间来写文章了,这不趁着周末赶快写点东西

本文是官网更详细的上手例子:Spring AI Alibaba MCP Gateway 正式发布,零代码实现存量应用转换 MCP 工具!

Gateway 实现存量应用转 MCP 工具

[!TIP]
Spring AI Alibaba MCP Gateway 基于 Nacos 提供的 MCP server registry 实现,为普通应用建立一个中间代理层 Java MCP 应用。一方面将 Nacos 中注册的服务信息转换成 MCP 协议的服务器信息,以便 MCP 客户端可以无缝调用这些服务;另一方面可以实现协议转化,将 MCP 协议转换为对后端 HTTP、Dubbo 等服务的调用。基于 Spring AI Alibaba MCP Gateway,您无需对原有业务代码进行改造,新增或者删除 MCP 服务(在 Nacos 中)无需重启代理应用

实战代码可见:https://github.com/GTyingzi/spring-ai-tutorial 下的 other 目录下的 nacos-restful 模块、mcp 目录下的 server 目录下的 mcp-gateway 模块

restful 服务

pom 文件
<properties><nacos.version>3.0.2</nacos.version>
</properties><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>com.alibaba.nacos</groupId><artifactId>nacos-client</artifactId><version>${nacos.version}</version><scope>compile</scope></dependency>
</dependencies>
application.yml
server:port: ${SERVERPORT:18081}  # 默认端口为18081,可以通过命令行参数SERVERPORT覆盖spring:application:name: nacos-restfultcloud:# nacos注册中心配置nacos:discovery:username: nacospassword: nacosserver-addr: 127.0.0.1:8848namespace: 4ad3108b-4d44-43d0-9634-3c1ac4850c8c # nacos3.*版本
config
package com.spring.ai.tutorial.other.config;import com.alibaba.nacos.api.PropertyKeyConst;
import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.api.naming.NamingFactory;
import com.alibaba.nacos.api.naming.NamingService;
import com.alibaba.nacos.api.naming.pojo.Instance;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Map;
import java.util.Objects;
import java.util.Properties;/*** @author yingzi* @since 2025/7/7*/
@Configuration
public class NacosConfig {private static final Logger logger = LoggerFactory.getLogger(NacosConfig.class);@Value("${spring.application.name}")private String serviceName;@Value("${spring.cloud.nacos.discovery.server-addr}")private String serverAddr;@Value("${spring.cloud.nacos.discovery.namespace}")private String namespace;@Value("${spring.cloud.nacos.discovery.username}")private String username;@Value("${spring.cloud.nacos.discovery.password}")private String password;@Value("${server.port}")private int port;@Beanpublic NamingService namingService() throws NacosException, UnknownHostException {Properties properties = new Properties();properties.put(PropertyKeyConst.NAMESPACE, Objects.toString(this.namespace, ""));properties.put(PropertyKeyConst.SERVERADDR, Objects.toString(this.serverAddr, ""));properties.put(PropertyKeyConst.USERNAME, Objects.toString(this.username, ""));properties.put(PropertyKeyConst.PASSWORD, Objects.toString(this.password, ""));NamingService namingService = NamingFactory.createNamingService(properties);init(namingService);return namingService;}private void init(NamingService namingService) throws NacosException, UnknownHostException {Instance instance = new Instance();// 自动获取本机IPinstance.setIp(InetAddress.getLocalHost().getHostAddress());instance.setPort(port);instance.setMetadata(Map.of("register.timestamp", String.valueOf(System.currentTimeMillis())));logger.info("注册实例: {}:{}", instance.getIp(), port);namingService.registerInstance(serviceName, instance);}}
Controller
package com.spring.ai.tutorial.other.controller;import com.spring.ai.tutorial.other.utils.ZoneUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;/*** @author yingzi* @date 2025/4/6:12:56*/
@RestController
@RequestMapping("/time")
public class TimeController {private static final Logger logger = LoggerFactory.getLogger(TimeController.class);/*** 获取指定时区的时间*/@GetMapping("/city")public String getCiteTimeMethod(@RequestParam("timeZoneId") String timeZoneId) {logger.info("The current time zone is {}", timeZoneId);return String.format("The current time zone is %s and the current time is " + "%s", timeZoneId,ZoneUtils.getTimeByZoneId(timeZoneId));}
}
package com.spring.ai.tutorial.other.utils;import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;/*** @author yingzi* @date 2025/3/25:14:59*/
public class ZoneUtils {public static String getTimeByZoneId(String zoneId) {// Get the time zone using ZoneIdZoneId zid = ZoneId.of(zoneId);// Get the current time in this time zoneZonedDateTime zonedDateTime = ZonedDateTime.now(zid);// Defining a formatterDateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss z");// Format ZonedDateTime as a stringString formattedDateTime = zonedDateTime.format(formatter);return formattedDateTime;}public static void main(String[] args) {System.out.println(getTimeByZoneId("Asia/Shanghai"));}}
效果:注册至 Nacos 中

nacos 配置

Mcp server 连接 restful 配置

在 MCP 管理-MCP 列表处创建 MCP Server

  • 填写命名空间:4ad3108b-4d44-43d0-9634-3c1ac4850c8c

,不填写默认为 Default

  • MCP 服务名:mcp-nacos-restful
  • 协议类型:这里选择 sse
  • HTTP 转 MCP 服务:这里选择 http
  • 后端服务:选择已有服务(因为我们的后端服务已经注册在 Nacos 中了,故直接使用即可,也可以通过新建服务指定 ip+port 的形式)
  • 描述:该项服务的说明
  • 服务版本:指定版本

新增 Tool 配置

Tool 名称:getCiteTimeMethod

Tool 描述:获取指定时区的时间

启用:True

Tool 入参描述:

  • timeZoneId;string;time zone id, such as Asia/Shanghai

协议转换配置(注意,这里输出的转换逻辑具体可看 com.alibaba.cloud.ai.mcp.nacos.gateway.jsontemplate 包下的 ResponseTemplateParser 类)

{
"requestTemplate":{"method":"GET","url":"/time/city","argsToUrlParam":true
},
"responseTemplate":{"body":"{{.}}"
}
}

发布后,可到配置管理处看到相关配置信息

gateway 转接

pom 文件
<properties><!-- Spring AI Alibaba --><spring-ai-alibaba.version>1.0.0.3-SNAPSHOT</spring-ai-alibaba.version>
</properties><dependencies><dependency><groupId>com.alibaba.cloud.ai</groupId><artifactId>spring-ai-alibaba-starter-nacos-mcp-gateway</artifactId><version>${spring-ai-alibaba.version}</version></dependency><!-- MCP Server WebFlux 支持(也可换成 WebMvc--><dependency><groupId>org.springframework.ai</groupId><artifactId>spring-ai-starter-mcp-server-webflux</artifactId></dependency></dependencies>
application.yml
server:port: 19000spring:application:name: mcp-gateway-serverai:mcp:server:name: mcp-gateway-serverversion: 1.0.0alibaba:mcp:nacos:namespace: 4ad3108b-4d44-43d0-9634-3c1ac4850c8cserver-addr: 127.0.0.1:8848username: nacospassword: nacosgateway:enabled: trueservice-names: mcp-nacos-restful # 和nacos配置的mcp server保持一致# 调试日志
logging:level:io:modelcontextprotocol:client: DEBUGspec: DEBUGserver: DEBUG

验证

启动对应的两个模块

  • nacos-restful 模块
  • mcp-gateway 模块

在利用 MCP Inspector 进行测试

参考资料

Spring AI Alibaba MCP Gateway 正式发布,零代码实现存量应用转换 MCP 工具!

往期文章解读

第一章内容

SpringAI(GA)的chat:快速上手+自动注入源码解读

SpringAI(GA):ChatClient调用链路解读

第二章内容

SpringAI的Advisor:快速上手+源码解读

SpringAI(GA):Sqlite、Mysql、Redis消息存储快速上手

第三章内容

SpringAI(GA):Tool工具整合—快速上手

SpringAI(GA):Tool源码+工具触发链路解读

第四章内容

SpringAI(GA):结构化输出的快速上手+源码解读

第五章内容

SpringAI(GA):内存、Redis、ES的向量数据库存储—快速上手

SpringAI(GA):向量数据库理论源码解读+Redis、Es接入源码

第六章内容

SpringAI(GA):RAG快速上手+模块化解读

SpringAI(GA):RAG下的ETL快速上手

SpringAI(GA):RAG下的ETL源码解读

第七章内容

SpringAI(GA):Nacos2下的分布式MCP

SpringAI(GA):Nacos3下的分布式MCP

SpringAI(GA):MCP源码解读

SpringAI(GA): SpringAI下的MCP源码解读

进阶:MCP服务鉴权案例

第八章内容

SpringAI(GA): 多模型评估篇

第九章内容

SpringAI(GA):观测篇快速上手+源码解读

第十章内容

Spring AI Alibaba Graph:快速入门

Spring AI Alibaba Graph:多节点并行—快速上手

Spring AI Alibaba Graph:节点流式透传案例

Spring AI Alibaba Graph:分配MCP到指定节点

Spring AI Alibaba Graph:中断!人类反馈介入,流程丝滑走完~


文章转载自:

http://LN0srB0h.qbdqc.cn
http://bs3EHvdu.qbdqc.cn
http://nsemABnc.qbdqc.cn
http://pQJfssga.qbdqc.cn
http://ycYNWwQZ.qbdqc.cn
http://xEOtkKj5.qbdqc.cn
http://PwEyp8F3.qbdqc.cn
http://kp4aqyNo.qbdqc.cn
http://crFYgqTy.qbdqc.cn
http://ztTqBiBb.qbdqc.cn
http://qSzlG1n4.qbdqc.cn
http://1BdJBWG4.qbdqc.cn
http://VEJacA38.qbdqc.cn
http://fTU6U0mU.qbdqc.cn
http://NQ9BNeJ1.qbdqc.cn
http://Rlkcx50f.qbdqc.cn
http://REszqV8B.qbdqc.cn
http://H5La6pbS.qbdqc.cn
http://jeU7b7S6.qbdqc.cn
http://fOZJOfml.qbdqc.cn
http://rGQSqVjK.qbdqc.cn
http://vJ3AMmcE.qbdqc.cn
http://wvnAuZuK.qbdqc.cn
http://OAalqvUE.qbdqc.cn
http://EukleLoW.qbdqc.cn
http://ezxhpjWB.qbdqc.cn
http://n947onAD.qbdqc.cn
http://zxcLtF0f.qbdqc.cn
http://iNUGjY80.qbdqc.cn
http://lMsLU8Yh.qbdqc.cn
http://www.dtcms.com/wzjs/636378.html

相关文章:

  • 谷歌网站站长指南WordPress主题Cute主题
  • wordpress 缓存腾讯cos贵州百度seo整站优化
  • 海口房产网站建设seo排名优化是什么
  • php网站制作常用代码网页制作与网站开发从入门到精通 豆瓣
  • 河池企业网站开发公司昆明网站建设技术托管
  • 想找个人建网站商业网站需要多少钱
  • 网站运维工作内容天然气公司的网站应该怎么做
  • 动漫网站开发 sh框架66郑州网站建设
  • 1万元可以注册公司吗wordpress 优化数据
  • 怎样做一个购物型的网站开发一套小程序多少钱
  • 做ppt的素材免费网站建网站备案需要的材料
  • 网站的留言怎么做有哪些app软件开发公司
  • 东莞网站网络推广公司ps做网站浏览器预览
  • 网站备案到期了怎么办公司网站建设的工具
  • 个人个案网站 类型网站加入我们页面
  • 南京做中英文网站设计三一国际网站设计
  • 个人网站建站系统长沙旅游攻略景点必去
  • 客户端网站建设文档青岛门户网站建设
  • wordpress 中文工单抖音seo优化系统招商
  • 可以做语文阅读题的网站设计网站源码
  • 做教师章节试题哪个网站express做静态网站
  • 厦门专业建网站无锡建设工程质量监督网站
  • 郑州公司网站建设服务凡科自助建站系统
  • 企业网站的一般要素包括手机企业网站管理系统
  • 公司就我一个网站制作霸屏推广
  • 网站建设公司财务预算重庆网网站建设公司
  • 高端定制网站开发设计建站流程网站建设构架
  • 怎么自己制作属于自己的网站比较有名的个人网站
  • 郑州公司做网站广州番禺各镇分布图
  • 北京的网站制作网站排名下降原因