How to disable auto-depend on the project but not the only jar when using maven in Intellij IDEA?

坚强是说给别人听的谎言 提交于 2019-12-10 12:20:37

问题


I am using Maven in Intellij IDEA 11.1.2, and i am working on two different projects and one of them depends on the other one.

Project A's pom.xml as following

   <dependency>
        <groupId>project.b</groupId>
        <artifactId>project.b</artifactId>
        <version>1.0-SNAPSHOT</version>
    </dependency>

Then IntellIj IDEA will automaticly depend on project B. Sometimes i can compile project A useing mvn command line, but the IDEA shows there are many errors in the source code, and the only way to fix this is removing the project b from the local file systems then removing it from the IDEA.

So i want to diable IDEA to auto-depend on the project but only the jar and do what the pom.xml tells it to do.

Thanks in advance.


回答1:


I believe you should tune dependency scope. Try specifying the scope as runtime - "This scope indicates that the dependency is not required for compilation, but is for execution. It is in the runtime and test classpaths, but not the compile classpath."




回答2:


As @CrazyCoder said,

SNAPSHOT dependencies are resolved via project source location

I just accept the fact.



来源:https://stackoverflow.com/questions/11321789/how-to-disable-auto-depend-on-the-project-but-not-the-only-jar-when-using-maven

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!