java maven .iml,Idea IntelliJ。如何创建maven项目。那么pom.xml和.iml文件呢?

i just started with java, and created a project.

its maven project (i hadn't use maven yet)

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.

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)

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,

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

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.

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

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

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.

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.

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

Hope this helps !

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值