'ClassNotFoundException: com.google.common.collect.Multimap JPAQuery

So I want to use JPAQuery to make filtration in my spring app but this line:

@PersistenceContext
EntityManager em;

JPAQuery <Customer> jpaQuery = new JPAQuery<>(em);

is throwing:

java.lang.NoClassDefFoundError: com/google/common/collect/Multimap

Caused by: java.lang.ClassNotFoundException: com.google.common.collect.Multimap at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) ... 72 more



Solution 1:[1]

Probably this piece of code is not making this specific error and somehow you are importing this class somewhere else, if you really need it make sure to properly import it with your dependency management system (maven, gradle) otherwise try to find which component is using this class and remove it.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Josep Pascual