How to disable auto-depend on the project but not

2019-06-09 02:00发布

问题:

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.