繁体   English   中英

如何将资源文件夹中 jar 文件中的类导入 package 中的另一个 class?

[英]How to import the classes within a jar file in the folder of resources, to another class within a package?

我已经使用 Intellj 创建了一个项目(实际上是 Spring,但我发现这个问题在Java项目和Spring项目之间没有任何关系),其层次结构如下:

  • 项目名称
    • 源代码
      • 主要的
        • java
          • com.xy
            • 控制器包
              • controller_class.java
            • 模型包
              • model_class.java
        • 资源
          • THIS.JAR

I don't quite understand, as on the level of java directory , I could create a java class which could directly use the class within THIS.JAR , while the file within those packages, ie, controller_class.java , I could not find the java class 在THIS.JAR内。 在前一种情况下,当我在THIS.JAR中输入THAT_CLASS时,工具提示将弹出Default package

This.jar is a jar file created by myself from another project, I used Maven and pom.xml has been configured. This.jar 包含一些其他模块,如postgresql/antlr 但是在java 目录controller_package的两个级别上,我都可以导入这些模块。 我四处寻找,没有找到解决办法。 作为 Java 的新手,它毁了我的一天,请问有没有人可以帮忙?

如果使用 Eclipse

您可以添加 jar 文件

1- select 右键单击您的项目和 select 属性

2- select java 构建路径

3- select 模块路径然后点击添加外部 JARS

然后检查 JRA SYSTEM LIBRARY 是否存在 jra 文件

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM