Reputation: 456
I was making a Minecraft plugin (with maven) and was going to use caffeine for a cache, but when I ran my server with the plugin jar, I got the error:
java.lang.NoClassDefFoundError: com/github/benmanes/caffeine/cache/Caffeine
I am updated to the latest version of caffeine (v3.0.3) and maven (v3.8.1). I honestly have nothing else to show other than that error. I only imported the following caffeine packages:
import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine
pom.xml (no repo)
<dependency>
<groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId>
<version>3.0.3</version>
</dependency>
server log: https://pastebin.com/zMzx37dk
Upvotes: 0
Views: 2129
Reputation: 117
It seems that the cause is that the library is not included in the jar file.
Try building by adding code like the following to plugins
in pom.xml.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</execution>
</executions>
</plugin>
Upvotes: 0