Not able to use org.ehcache in project

65 Views Asked by At

I'm trying to use echache but I can't seem to use in my project. I'm getting the following error:

"Cannot resolve symbol 'ehcache'"

I'm using IntelliJ IDEA and have installed Maven 3.9.4. I've tried mvn clean install and mvn dependency:resolve. After spending around 6+ hours on this, I'm not sure what step to follow now.

Main.java file:

package org.example;

import org.ehcache.*;
public class Main {
    public static void main(String[] args) {
        System.out.println("Hello world!");
    }
}

pom.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.example</groupId>
    <artifactId>demo3</artifactId>
    <version>1.0-SNAPSHOT</version>
    <properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.ehcache</groupId>
                <artifactId>ehcache</artifactId>
                <version>3.1.3</version>
            </dependency>
        </dependencies>
    </dependencyManagement>
</project>

mvn clean install output:

[INFO] Scanning for projects...
[INFO] 
[INFO] -------------------------< org.example:demo3 >--------------------------
[INFO] Building demo3 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ demo3 ---
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ demo3 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ demo3 ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /Users/asad-raheem/Documents/workspace/demo3/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /Users/asad-raheem/Documents/workspace/demo3/src/main/java/org/example/Main.java:[3,1] package org.ehcache does not exist
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.634 s
[INFO] Finished at: 2023-09-22T02:23:00+05:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project demo3: Compilation failure
[ERROR] /Users/asad-raheem/Documents/workspace/demo3/src/main/java/org/example/Main.java:[3,1] package org.ehcache does not exist
[ERROR] 
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

Process finished with exit code 1
0

There are 0 best solutions below