Spring boot项目获取所有请求路径

 @GetMapping("/getAllUrl")
    public void getAllUr(HttpServletResponse response) throws Exception {
        RequestMappingHandlerMapping mapping = applicationContext.getBean(RequestMappingHandlerMapping.class);
        Map<RequestMappingInfo, HandlerMethod> map = mapping.getHandlerMethods();

        List<List> sheetData = new ArrayList<>();

        Set<RequestMappingInfo> requestMappingInfos = map.keySet();
        for(RequestMappingInfo requestMappingInfo: requestMappingInfos) {
            List<String> rowData = new ArrayList<>();

            // beanName
            HandlerMethod handlerMethod = map.get(requestMappingInfo);
            rowData.add(handlerMethod.getBean().toString());

            // 全路径
            String fullClassPath = handlerMethod.getBeanType().getName();
            rowData.add(fullClassPath);

            // 请求地址
            Set<String> patterns = requestMappingInfo.getPatternsCondition().getPatterns();
            for(String url :patterns) {
                rowData.add(url + " ");
            }

            // 请求方式
            Set<RequestMethod> requestMethods = requestMappingInfo.getMethodsCondition().getMethods();
            for(RequestMethod requestMethod: requestMethods) {
                rowData.add(requestMethod.name() + " ");
            }

            sheetData.add(rowData);
        }
        // todo 写入excel
    }

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Spring Boot项目的流程可以简单概括为以下几个步骤: 1. 创建项目:使用Spring Initializr或者手动创建一个Maven或Gradle项目,并添加Spring Boot的依赖。 2. 配置项目:在项目的配置文件(application.properties或application.yml)中设置相关的配置,如数据库连接、端口号等。 3. 创建实体类:根据业务需求创建领域模型的实体类,使用注解定义实体的属性、关系和约束。 4. 创建数据访问层:使用Spring Data JPA或其他持久化框架,创建Repository接口,定义对数据库的增删改查操作。 5. 创建服务层:编写业务逻辑处理代码,可以使用@Service注解将类标记为服务组件,并注入Repository接口。 6. 创建控制器层:编写RESTful API接口的实现,使用@RestController注解将类标记为控制器,并使用@RequestMapping等注解定义请求路径请求方法。 7. 测试项目:编写单元测试和集成测试,保证项目的正确性和稳定性。 8. 打包和部署:使用Maven或Gradle进行项目打包,生成可执行的jar或war文件,并部署到服务器或云平台上。 9. 运行项目:启动应用程序,并通过浏览器或其他客户端发送HTTP请求进行测试和访问。 10. 监控和维护:根据实际需求,配置日志、监控和安全等功能,保证项目的稳定运行。 以上是一个简单的Spring Boot项目的流程,具体的实现方式和细节可以根据具体的需求和开发团队的约定进行调整和优化。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值