Idea IntelliJ。如何创建maven项目。那么pom.xml和.iml文件呢? [英] Idea IntelliJ. how creating maven project. what about pom.xml and .iml files

查看:3685
本文介绍了Idea IntelliJ。如何创建maven项目。那么pom.xml和.iml文件呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始使用java,并创建了一个项目。
它的maven项目(我还没有使用maven)

i just started with java, and created a project. its maven project (i hadn't use maven yet)

所以我的项目有两个模块A和B.
和B取决于A ,A取决于远程maven回购中的一些。和B还取决于一些远程回购。
它在Idea IntelliJ中工作正常,并且可以很好地构建jar。

so my project have two modules A and B. and B depends on A, and A depends on some from remote maven repo. and B also depends on some remote repo. its works fine in Idea IntelliJ and build jars fine.

但afaik .iml文件是Idea IntelliJ特有的。和pom.xml是maven特有的。
当我检查文件时为什么项目的所有权限都写在.iml文件和.idea dir而不是pom.xml(s)

but afaik .iml files are Idea IntelliJ specific. and pom.xml is maven specific. and when i inspect files why all depedecy of project is written in .iml files and .idea dir instead of pom.xml(s)

如果你想要要查看真实世界的来源,然后这里,这是它深入学习java的alpha项目。
当我尝试在 travis-ci.org 上建立项目时,它无法解决项目的依赖关系

if you want to see the real world source then here it is but its alpha project for learning java deeply. and when i try to build project on travis-ci.org it unable to resolve dependencies of project

推荐答案

Meghraj,

我已经分叉了您的WebTrimmer回购在这里: https://github.com/ajorpheus/WebTrimmer 并解决了几个问题这阻碍了成功构建:

I have forked your WebTrimmer repo here : https://github.com/ajorpheus/WebTrimmer and fixed a couple of issues which were preventing a successful build:


  1. travisci失败,因为你在lib文件夹中有三个罐子,因为它们不可用于CI做maven构建。

    修复是删除这三个jar并引入相应的maven依赖项,如 this 提交。


  2. 在添加maven依赖项时,需要排除,如下所示:以下工件无法解析:javax.jms:jms:jar:1.1


  3. WebTrimmerUI依赖于它的兄弟模块WebTrimmerEngine中的类,因此需要相应的依赖。

  1. The travisci fails because you have three jars in the lib folder which are not available to the CI since it's doing a maven build.

    The fix was to remove those three jars and introduce corresponding maven dependencies as in this commit.

  2. While adding the maven dependencies an exclusion was needed as noted here : The following artifacts could not be resolved: javax.jms:jms:jar:1.1

  3. The WebTrimmerUI depends on the classes in it's sibling module WebTrimmerEngine, therefore a corresponding dependency is needed.

我已将项目转换为与IDE无关的纯maven项目。通过上述更改,我可以从命令行构建项目,并期望travisci也能够。

I have converted the project into a pure maven project which is IDE-agnostic. With the above changes, I can build the project from command line and expect that the travisci should be able to as well.

关于为什么依赖项重复的问题.iml ---这不是CI工作失败的原因。该文件中的依赖项是pom.xml中依赖项的快照。当用户手动重新导入maven项目时,此快照会更新;如果maven项目设置为自动导入,则会自动更新。

正如Peter Lawrey在上面的评论中提到的,如果你在项目中添加一个jar,maven不知道它,它只会出现在.iml文件中。

Regarding the question about why the dependencies are duplicated in .iml --- That's not the reason the CI job fails. The dependencies in that file are a snapshot of the dependencies in the pom.xml. This snapshot is updated when the maven project is re-imported manually by the user, or automatically if the maven project is set to 'Auto-Import'.
As Peter Lawrey mentioned in his comment above, if you add a jar to the project, maven does not know about it and it will be present only in the .iml file.

一般来说,搜索和添加maven依赖项,以下一直对我有用: https://stackoverflow.com/a/10178586/325742

In general, to search and add a maven dependency, the following has always worked for me: https://stackoverflow.com/a/10178586/325742

希望这会有所帮助!

这篇关于Idea IntelliJ。如何创建maven项目。那么pom.xml和.iml文件呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆