After mvn install,我在外部库中看不到JAR文件。

huangapple go评论82阅读模式
英文:

After mvn install I dont see jars in External Libraries

问题

这是我第一次在生产环境中使用Maven。我遇到了一些问题。我们正在使用Maven模块,假设我有两个模块:

  • 前端
  • 后端

其中,前端模块使用了一些后端模块的类,因此我们在前端项目中有对后端项目的依赖关系。所以,在构建时,我运行mvn install来构建并将后端和前端的JAR包复制到本地存储库。一切都正常工作,所有新创建的JAR包都位于.m2目录中。

但即使如此,IntelliJ不识别这些依赖关系。在前端项目中,当我使用后端类时,它告诉我找不到这个类。此外,在“External Libraries”选项卡中,我找不到这个JAR包。

有什么想法是什么出了问题吗?

英文:

This is my first time working with maven on production. And I am struggling. We are using maven modules and lets say I have two modules

  • frontend
  • backend

Where, frontend is using some of backend classes, so we have dependencies from frontend project to backend project.
So what I am doing when building with maven is running mvn install to build and copy backend and frontend jars to local repository. And it is working correctly, everything is passing and newly created jars are located in .m2 directory.

But even so, Intellij does not see this dependencies. And in frontend project, when I am using backend class it is telling me that this class is not found. In addition in External Libraries tab I cant find this jar.

Any idea what is wrong?

答案1

得分: 0

你应该将项目作为Maven项目打开/导入。

如果你从在线仓库(svn/git)获取项目,你可以使用JIdea内置的工具来完成这个任务。

新建 -> 从版本控制导入项目

在添加项目后,执行完整的 mvn clean install,如果pom.xml文件中列出了所需的依赖项,这应该可以让你开始工作。

任何时候,如果你需要重新加载依赖项,你可以使用 maven reimport

你可以通过进入 查看 -> 工具窗口 -> maven 来启用Maven项目的侧边栏。

在Maven中,你可以使用Apache Maven Dependency Plugin,目标是 dependency:purge-local-repository 来从本地仓库中删除项目的依赖项,然后重新下载它,

mvn dependency:purge-local-repository

了解更多关于处理模块依赖关系的信息,请点击这里

英文:

You should open/import the project as a maven project.

If you are fetching the project from an online repository (svn/git) you can use JIdea built in tools for this.

New -> Project from Version Control

After adding the project do a complete mvn clean install, this should get you going if the pom.xml files are having required dependencies listed.

At any point of time, if you need to reload the dependencies you can use maven reimport.

You can enable a side bar for maven project by going into, View -> Tool Windows -> maven

In Maven, you can use Apache Maven Dependency Plugin, goal dependency:purge-local-repository to remove the project dependencies from the local repository, and re-download it again,
mvn dependency:purge-local-repository

Read more about working with module dependencies here

huangapple
  • 本文由 发表于 2020年7月22日 14:58:11
  • 转载请务必保留本文链接:https://go.coder-hub.com/63028564.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定