【问题标题】:maven-compiler-plugin compile project with jar librarymaven-compiler-plugin 用 jar 库编译项目
【发布时间】:2018-11-25 06:16:16
【问题描述】:

我有一个 maven 项目,它有一个库 (hello1.jar),我用 IDEA 添加了它。在这个 jar 文件中,我有 ru.training.Hello1 类。在项目中,我有类 Hello2,其中包含字段 Hello1 hello1。当我尝试使用 maven 生命周期编译项目时,出现错误:

[ERROR] 无法执行目标 org.apache.maven.plugins:maven-compiler-plugin:3.6.1:compile (default-compile) on project Learning: Compilation failure: Compilation failure:

[ERROR] /C:/Projects/Learning/src/main/java/reflection/Hello2.java:[3,19] 包 ru.training 不存在

[ERROR] /C:/Projects/Learning/src/main/java/reflection/Hello2.java:[7,13] 找不到符号

[ERROR] 符号:类 Hello1

我可以做些什么来修复这个错误?

【问题讨论】:

  • 将 jar 添加到您的 pom 文件中..不在 IDE 中....
  • 谢谢你,朋友。我用它来将本地 jar 添加到 pom:*.com/questions/4955635/…

标签: maven jar maven-compiler-plugin


【解决方案1】:

在这种情况下,您需要将本地 jar 文件添加到本地存储库,然后编译项目。如何添加本地 jar 我在这里读过:How to add local jar files to a Maven project?

【讨论】: