【发布时间】:2023-03-20 06:11:01
【问题描述】:
我为数据可视化工具开发了一个插件。现在我想在里面使用redis。当我在另一个项目(不在我的插件内)中尝试从here 获取的以下 redis 代码时,它运行良好。
//Connecting to Redis server on localhost
Jedis jedis = new Jedis("localhost");
System.out.println("Connection to server sucessfully");
//check whether server is running or not
System.out.println("Server is running: "+jedis.ping());
但是当我在我的插件中使用 Jedis 时,我得到了 Caused by: java.lang.NoClassDefFoundError: redis/clients/jedis/Jedis 和 Caused by: java.lang.NoClassDefFoundError: redis/clients/jedis/Jedis 错误。为了将我的插件安装到这个数据可视化工具中。我需要创建一个我所做的 jar 文件,并且它在不添加 jedit 部分的情况下运行良好。
我正在使用 IntelliJ Idea,我创建了一个工件并从顶部菜单中的 build - build artifact 选项卡中构建它。我还在 pom.xml 中添加了 jedis jar 文件作为依赖项(这是一个 maven 项目),我将它添加为项目结构中的库,并添加了 jedis jar 文件作为提取目录和库以及项目结构的 artifacts 选项卡菜单。然后我将 jedis jar 文件添加到我的项目 .classpath 文件中,如下所示:
<classpathentry kind="src" path="src/main/resources/jedis-2.1.0-sources.jar" including="**/*.java"/>
所以当我打开我的 jar 文件时,我可以看到“redis/clients/jedis”路径中有 Jedis.java 文件。我的 jar 文件的根路径中还有 jedis jar 文件。但即使这样也行不通。它在 runtime 给出了上述错误。我哪里做错了?
【问题讨论】:
标签: java maven redis cytoscape.js