At one point I wanted to write a simple program that connects Java to Redis, tutorialspoint https://www.tutorialspoint.com/redis/redis_java.htm I was addicted to it when I saw it and tried it exactly, so I made a memorandum.
As introduced, the flow of downloading the Jedi jar from the repository, passing it through the classpath, writing a Java sample application, importing the Jedi and connecting it to Redis is the same, but the DL of jedis.jar is From here, if you use jedis-2.1.0-sources.jar obtained from the link, you will get the following error when using the Jedi class.
Exception in thread "main" java.lang.NoClassDefFoundError: redis/clients/jedis/Jedis
at RedisJava.main(RedisJava.java:6)
Caused by: java.lang.ClassNotFoundException: redis.clients.jedis.Jedis
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 1 more
I wondered if the class itself was wrong (details unknown) If you go back in the path of the download URL http://repo1.maven.org/maven2/redis/clients/jedis/ I can download a newer version of jedis.jar, so I tried using 3.0.0 and it ran fine (connecting to Redis from the java sample app). This is the DL I did http://repo1.maven.org/maven2/redis/clients/jedis/3.0.0/jedis-3.0.0.jar
Connection to server sucessfully
Server is running: PONG
}}}
Recommended Posts