• JAVA开发错误总结(仅记录遇到的错误---后续不断更新......)


    =======华丽分割线(工具总结)=====================

    1:Maven项目中junit测试找不到主类的问题

    Class not found com.test.utils.test
    java.lang.ClassNotFoundException: com.test.utils.test
    	at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java:688)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClasses(RemoteTestRunner.java:421)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:444)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
    

    解决方法:找到图一修改成为图二

    图1:

    图2:

    ========华丽分割线(数据库总结)==================

     Mongo查询正确格式:

    Query query = new Query();
    String startTime = "2014-03-29 16:58";
    String endTime = "2014-04-09 14:16";
    query.addCriteria(Criteria.where("time").gte(startTime).lte(endTime));

    json格式:

    查询时间错误案例:

    报错:org.springframework.data.mongodb.InvalidMongoDbApiUsageException: Due to limitations of the com.mongodb.BasicDBObject, you can't add a second 'time' expression specified as 'time

    Query query = new Query();
    String startTime = "2014-03-29 16:58";
    String endTime = "2014-04-09 14:16"; query.addCriteria(Criteria.where("time").is(startTime).and("time").is(endTime));

    分析:根据前面的json格式可以看出time其实已经存在了,导致二次创建time(看下面事例)

     Query query = new Query();
    String startTime = "2014-03-29 16:58";
    query.addCriteria(Criteria.where("time").is(startTime).and("sex").is("男"));
    

    ====================================================================

      

  • 相关阅读:
    ElasticSearch 清理索引
    Docker 服务接入SkyWalking
    Promethues mysql_exporter 集中式监控
    修改SVN密码自助平台
    快速排序(golang)
    ElasticSearch Xpack集群认证和elasticsearch-head配置
    Ansible一个tasks失败则终止剩余的task
    Consul安装
    最纯净的开发者技术交流社群
    Flutter中的报错:(IOS pod 版本错误) error: compiling for iOS 8.0, but module 'xxx' has a minimum deployment target of iOS 9.0
  • 原文地址:https://www.cnblogs.com/byteworld/p/6029745.html
Copyright © 2020-2023  润新知