Intellij mvn git hbase

使用intellij查看hbase源码的过程中,处理hbase 1.1.2的时候万事OK,但是git checkout到2.0.1的时候就悲剧了,会发现 imp文件里面的依赖的一些jar还是1.1.2的时候的jar,如果手动给某些项目加上module dependency的话会缓解一些,但是那么多project怎么加依赖呀。


mvn命令各种姿势都OK,唯独intellij不工作。

Intellij 14 Ultimate

mvn: apache-maven-3.3.9(external)  apache-maven-3.2.5(internal) 

查了baidu intellij add dependency module 然后在stackoverflow上碰到了一个答案。原来是intellij的问题,


解决办法就是"Use Maven3 to import project"取消这个选项。


这里估计是hbase 2.0里面的pom和1.1.2里面的pom有些区别,而导致了intellij不能正常识别吧。


https://stackoverflow.com/questions/11454822/import-maven-dependencies-in-intellij-idea


Strangely enough almost every other post advises to check the "Use Maven3 to import project" option to solve this issue while actually unchecking it solved the issue for me. Why? I don't know. Thanks!


https://youtrack.jetbrains.com/issue/IDEA-98425


Thought I'd throw my $0.02 in here: For me, the fix to this was to go to

File [menu] -> Settings -> maven -> importing and uncheck "use maven3 to import project"

ref: http://youtrack.jetbrains.com/issue/IDEA-98425 (which may have a few other ideas too)

Update: Ran into this again, with IntelliJ 15 this time, which has no "use maven3 to import" option available anymore. The cause was that sometimes IntelliJ "doesn't parse maven dependencies right" and if it can't parse one of them right, it gives up on all of them, apparently. You can tell if this is the case by opening the maven projects tool window (View menu -> Tool Windows -> Maven Projects). Then expand one of your maven projects and its dependencies. If the dependencies are all underlined in red, "Houston, we have a problem". enter image description here

You can actually see the real failure by mousing over the project name itself.

enter image description here

In my instance it said "Problems: No versions available for XXX" or "Failed to read descriptor for artifact org.xy.z" ref: https://youtrack.jetbrains.com/issue/IDEA-128846 andhttps://youtrack.jetbrains.com/issue/IDEA-152555

It seems in this case I was dealing with a jar that didn't have an associated pom file (in our maven nexus repo, and also my local repository). If this is also your problem, "urrent work around: if you do not actually need to use classes from that jar in your own code (for instance a transitive maven dependency only), you can actually get away with commenting it out from the pom (temporarily), maven project reload, and then uncomment it. Somehow after that point IntelliJ "remembers" its old working dependencies. Adding a maven transitive exclude temporarily might also do it, if you're running into it from transitive chain of dependencies."

Another thing that might help is to use a "newer version" of maven than the bundled 3.0.5. In order to set it up to use this as the default, close all your intellij windows, then open preferences -> build, execution and deployment -> build tools -> maven, and change the maven home directory, it should say "For default project" at the top when you adjust this, though you can adjust it for a particular project as well, as long as you "re import" after adjusting it.

Other things that might help: deleting your intellij cache folders (windows: HOMEPATH/.{IntellijIdea,IdeaC}XXX linux ~/.IdeaIC15) and/or uninstalling and reinstalling IntelliJ itself. GL!



2 解决了上面的问题还有其他问题

当从2.0.0 切换到hbase master分支的时候,也就是3.0.0状态的时候,却发现还是到处红叉。

三板斧:

1 mvn clean install -DskipTests     这一步是因为compile过程中报错了,需要本地仓库有一个module的jar,然后另一个正则compile的module依赖它,所以要先install一把

2 mvn clean compile -DskipTests   这一步的目的其实是生成protobuf相关的java类文件到target目录中。hbase中每个protobuf出现的地方都在pom中进行了特别的配置,指定了生成类放置的位置。

3 把一些protobuf相关的module中的target/generated-sources/java 目录使用右键设置为Mark Directory As --> generated-source-root    这样Intellij会把这个目录中的java类识别为java,否则只是当成普通文件。但是有一个问题就是protobuf生成的文件可能太大,需要做如下改动

https://my.oschina.net/shipley/blog/510762


 其设置在...JetBrains\IntelliJ IDEA Community Edition 14.1.4\bin 目录下的idea.properties文件。

#---------------------------------------------------------------------
# Maximum file size (kilobytes) IDE should provide code assistance for.
# The larger file is the slower its editor works and higher overall system memory requirements are
# if code assistance is enabled. Remove this property or set to very large number if you need
# code assistance for any files available regardless their size.
#---------------------------------------------------------------------
# idea.max.intellisense.filesize=2500
idea.max.intellisense.filesize=5000

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值