intellij not finding maven imports from third part

2019-06-27 05:48发布

问题:

My pom.xml includes

    <repositories>
    <repository>
        <id>spantus</id>
        <name>spantus sourceforge</name>
        <url>http://spantus.sourceforge.net/maven/global/</url>
    </repository>
</repositories>

and

    <dependency>
        <groupId>net.sourceforge</groupId>
        <artifactId>javaml</artifactId>
        <version>0.1.5</version>
    </dependency>

My code includes the line

    net.sf.javaml.core.Instance instance;

with error

cannot resolve symbol 'net'

(Similarly, imports fail).

Yet mvn package works fine, which indicates it's compiling and finding the dependency. Furthermore the pom.xml shows no error on the dependency.

I've manually navigated the source in version 0.1.5 to make sure the package name for the import is correct. (But mvn compiles it anyway, so no matter).

I have done "invalidate cache and restart" and the error persists."

How can I get intellij to work?

回答1:

Including this dependency worked for me

<dependency>
    <groupId>net.sf</groupId>
    <artifactId>javaml</artifactId>
    <version>0.1.7</version>
</dependency>

Without setting any repository.

Hope it helps