=======华丽分割线(工具总结)=====================
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("男"));
====================================================================