别人写的方法,只知道大概

img


如图,我只知道这个findby方法是用来寻找某个东西 ,但我不知道它是怎么实现排序并输出的

大概率是数据库排序,但是代码没有前因后果看不出什么东西

  • 你可以参考下这个问题的回答, 看看是否对你有帮助, 链接: https://ask.csdn.net/questions/1046739
  • 你也可以参考下这篇文章:对象不支持find属性或方法
  • 除此之外, 这篇博客: find命令之跳过指定目录查询中的 find命令之跳过指定目录查询 部分也许能够解决你的问题, 你可以仔细阅读以下内容或跳转源博客中阅读:
  • 有时候在使用find查询时想跳过其中的目录(子目录),命令上基本是用到find的-prune和-path参数,但其中有几个注意点

    1. -path路径不能加入结尾的/
    2. -path路径和find路径保持一致
      参考如下几行命令

    下面这条命令想在当前目录下的test/config/目录但跳过mappings子目录查找xml结尾的文件,因为-path的路径参数加了/结尾,所以实际查到的结果并没有跳过mappings子目录(返回的第二行)

    [yangwz@localhost ~]$ find test/config/ -path "test/config/mappings/" -a -prune -o -name "*.xml" -print
    test/config/spring-context-activiti.xml
    test/config/mappings/catalog/theme/ThemeCataDao.xml
    test/config/spring-context.xml
    test/config/spring-context-jedis.xml
    test/config/mybatis-config.xml
    test/config/spring-context-dubbo.xml
    

    下面这条命令去掉了-path路径最后面的/,所以查询结果达到预期

    [yangwz@localhost ~]$ find test/config/ -path "test/config/mappings" -a -prune -o -name "*.xml" -print
    test/config/spring-context-activiti.xml
    test/config/spring-context.xml
    test/config/spring-context-jedis.xml
    test/config/mybatis-config.xml
    test/config/spring-context-dubbo.xml
    

    下面两条命令演示path路径和find不一致的区别
    -path路径和find路径不一致时,查询结果也是没有达到预期,即find是在当前路径开始查,而-path写的是绝对路径

    [yangwz@localhost ~]$ find test/config/ -path "/home/yangwz/test/config/mappings" -a -prune -o -name "*.xml" -print
    test/config/spring-context-activiti.xml
    test/config/mappings/catalog/theme/ThemeCataDao.xml
    test/config/spring-context.xml
    test/config/spring-context-jedis.xml
    test/config/mybatis-config.xml
    test/config/spring-context-dubbo.xml
    

    而当两者路径一致时,查询结果达到预期

    [yangwz@localhost ~]$ find /home/yangwz/test/config/ -path "/home/yangwz/test/config/mappings" -a -prune -o -name "*.xml" -print
    /home/yangwz/test/config/spring-context-activiti.xml
    /home/yangwz/test/config/spring-context.xml
    /home/yangwz/test/config/spring-context-jedis.xml
    /home/yangwz/test/config/mybatis-config.xml
    /home/yangwz/test/config/spring-context-dubbo.xml