1

IntelliJ says Cannot resolve symbol 'google'. about this import:

import com.google.common.cache.LoadingCache;

Even though I have added the dependency correctly and it doesn't complain about it:

<dependency>
    <groupId>com.google.guava</groupId>
    <artifactId>guava</artifactId>
    <version>19.0</version>
</dependency>

I have updated my Maven repository. I have Maven auto-import enabled in IntelliJ IDEA. My project is using SDK version 1.8. Based on numerous examples on the web, this should work, but it doesn't.

I found this about a similar (although not the same issue, as my code doesn't compile). I tried invalidating the cache and restarting, but it didn't help. The top answer also suggests deleting the IDEA system directory. I don't know if this is a good idea and how much stuff breaks if I do that.

Community
  • 1
  • 1
Atte Juvonen
  • 4,922
  • 7
  • 46
  • 89
  • If it is "only" IntelliJ thay is messed up, usually invalidating caches and reimporting the Maven project solves the issue – Tome Dec 30 '16 at 13:45
  • Reimporting the project and invalidating caches multiple times seems to have broken everything. Now it's saying "cannot resolve" about everything! :( – Atte Juvonen Dec 30 '16 at 13:59
  • @AtteJuvonen Could you try to maven build from command line ? – Amit Dec 30 '16 at 13:59

2 Answers2

1

I had the same problem and was trying all solutions to import Guava cache manager.

But the mistake I made was, did not add dependencies properly. Please do check pom.xml before trying any solution.

   <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>25.0-jre</version>
    </dependency>
    <!-- these are the dependencies i missed -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-beans</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context-support</artifactId>
        <version>4.3.10.RELEASE</version>
    </dependency>`
Hema
  • 988
  • 1
  • 16
  • 38
0

If anyone else has a similar issue, reading through pom.xml may be helpful. Turns out I had <properties> defined twice. For some reason it was not causing problems before adding the Guava dependency. After removing the duplicate definition, everything started working again.

Atte Juvonen
  • 4,922
  • 7
  • 46
  • 89