ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
用户点个按钮如何与服务端交互? 发布的HTTP接口如何访问数据库等其他操作? 发布EJB接口,客户端调用即可 # 1、public定义interface ``` package nc.app.itf; import java.util.Map; import nc.vo.pub.BusinessException; /** * * @author Administrator * */ public interface IAppRestService { public Object doAction(String actionImpl ,Map params)throws BusinessException; } ``` # 2、private实现interface ``` package nc.app.impl; import java.util.Map; import nc.app.itf.IAppRestService; import nc.vo.pub.BusinessException; public class AppRestServiceImpl implements IAppRestService { public Object doAction(String actionImpl, Map params) throws BusinessException { return null; } } ``` # 3、 配置upm发布接口 tx="CMT" 表示启用事物,"NONE" 表示不启用事物 singleton="true" 表示单例 "false" 表示非单例 remote="true" 表示远程组件 supportAlias="true" 表示支持别名 priority="0" 表示优先级为0 > 通常固定 配置 priority="0" remote="true" singleton="true" supportAlias="true" tx="CMT" 偶尔不需要事物 priority="0" remote="true" singleton="true" supportAlias="true" tx="NONE" ``` <public> <component priority="0" remote="true" singleton="true" supportAlias="true" tx="CMT"> <interface>nc.app.itf.IAppRestService</interface> <implementation>nc.app.impl.AppRestServiceImpl</implementation> </component> </public> ``` ![](https://img.kancloud.cn/30/31/3031e83980cdd9eae92d4c33560686ef_1172x484.png) # 4、EJB部署重启 一般eclipse 重启项目中间件即可生效,不生效可重启,检查upm文件的name是否重复,有些NCHOME有BUG不写**name="pu20220220"** 会被其他接口覆盖,默认是取文件名为 **name** 可以不配置**name** > module name="pu20220220" ![ ](images/screenshot_1645352682470.png)