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

纯php网站开发的网站wordpress和vue哪个好

纯php网站开发的网站,wordpress和vue哪个好,wordpress 国内 优化,app软件开发技术pdf百度云在你的场景下,如果刷题微服务通过 Maven 引入了 auth-api 模块,并且 auth-api 中定义了 Feign 接口(例如获取用户名的方法),你需要在 刷题微服务 中的启动类上配置 EnableFeignClients 注解。配置中 basePackages 参数…

在你的场景下,如果刷题微服务通过 Maven 引入了 auth-api 模块,并且 auth-api 中定义了 Feign 接口(例如获取用户名的方法),你需要在 刷题微服务 中的启动类上配置 @EnableFeignClients 注解。配置中 basePackages 参数应该填写 Feign 接口所在包的 全限定包名(即 auth-api 模块中定义接口的包路径)。


项目结构如下

 

Feign 接口定义(在 auth-api 模块中)

  • name: 必须和权限微服务 auth-servicespring.application.name 保持一致。
  • path: 对应权限服务中的接口路径。

刷题微服务中的配置(QuestionApplication

在刷题微服务中引入 auth-api 模块,并在启动类上配置 @EnableFeignClients,指向 Feign 接口所在的包 com.provider.auth.api

Maven 引入 auth-api

question-servicepom.xml 中添加依赖:

<dependency>
    <groupId>com.provider</groupId>
    <artifactId>auth-api</artifactId>
    <version>1.0.0</version>
</dependency>

启动类配置 @EnableFeignClients

启动类的完整配置:

package com.provider.question;import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;@EnableFeignClients(basePackages = "com.provider.auth.api") // 指向 auth-api 中的接口包
@SpringBootApplication
public class QuestionApplication {public static void main(String[] args) {SpringApplication.run(QuestionApplication.class, args);}
}


权限服务的配置(auth-service

在权限微服务中,确保接口路径 /auth/getUsername 存在并正确实现:

package com.provider.auth.service;import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;@RestController
@RequestMapping("/auth")
public class UserService {@GetMapping("/getUsername")public String getUsername(@RequestParam("userId") Long userId) {// 返回用户名逻辑return "User-" + userId;}
}
  • 确保 auth-servicespring.application.name 配置为 auth-service

spring:
  application:
    name: auth-service
server:
  port: 8081


调用接口示例

在刷题微服务中,注入 UserFeignClient 并调用权限微服务的接口:

package com.provider.question.service;import com.provider.auth.api.UserFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;@Service
public class QuestionService {@Autowiredprivate UserFeignClient userFeignClient;public String getUsername(Long userId) {return userFeignClient.getUsername(userId);}
}

关键点总结

  1. @EnableFeignClients 的配置

    • 配置 basePackages 为 Feign 接口所在的包路径,例如:com.provider.auth.api
    • 这个包路径是 auth-api 模块中定义的 Feign 接口所在的包名。
  2. Maven 依赖

    • 确保刷题微服务正确引入了 auth-api 模块的依赖。
  3. 服务名匹配

    • 确保 @FeignClient(name = "auth-service") 中的 name 与权限微服务的 spring.application.name 一致。
  4. 注册中心

    • 如果使用注册中心(如 Eureka、Nacos),确保权限服务正常注册,并能被刷题微服务发现。
http://www.yayakq.cn/news/986626/

相关文章:

  • 网站建设的五个基本要素知名企业招聘信息
  • 网站优化建设青岛哪里做网站
  • 怎样做网站视频网站模板助手
  • 青浦网站设计如何设置网站icon
  • 256内存vps装wordpress海口百度seo公司
  • 用dw做的网站wordpress 发布文章 自定义栏目
  • 怎么做网站注册名密码公司关于网站建设的通知
  • 做彩票网站能挣到钱吗?网络营销公司介绍
  • 绑定手机网站文件夹外链网站推荐
  • 网站数据分析网易邮箱用企业邮箱账号怎么登录
  • 大连网站建设-中国互联网片钢筋
  • 开封旅游网站建设方案策划书深圳公司网站建设服务
  • 青岛专业网站制作设计网址价格
  • 江苏建设厅网站查询企业网站建设推广方案怎么写
  • 下载学校网站模板网页制作简易代码
  • 建设项目自主验收网站网页设计与制作教程期末考试试题
  • 公司app与网站建设方案网络广告推广案例
  • xampp wordpress 建站网络公司做网站后期注意
  • 网站用户体验准则详情页的五大模块
  • 视频网站如何做营销数字化文化馆网站建设
  • 开发网站的成本深圳品牌手表有哪些
  • wordpress黑镜百度云盘连云港关键字优化预订
  • 哪些行业对做网站的需求大东道设计有限公司
  • 做轻时尚的网站手机程序开发
  • 南昌互联网网站开发什么是网站的主页
  • 深圳荷坳网站建设公司摄影官网
  • 陕西网站建设优化技术广州网站建设招标
  • 本网站建设中做笔记的网站源码
  • 台州网站搜索引擎优化乌镇网站建设标书
  • 深圳网站建设网络鹿泉区城乡建设局网站