Atihska
Atihska

Reputation: 5126

Class not able to recognize maven dependencies

I am trying to create a maven project. I added the dependencies as jar files and importing them in my class. But the class doesn't recognize it.

I tried a couple of options and serached but couldn't resolve. Please guide.

Attached below is the screenshot of my project str enter image description here

enter image description here

Upvotes: 0

Views: 2086

Answers (2)

Yogesh Ghimire
Yogesh Ghimire

Reputation: 442

Try this:

Right click your project and select maven then click update project. Select the project and select force update of snapshots/releases option. Then refresh the project and build it (if you do not see compilation error after updating).

Upvotes: 1

Tanvi B
Tanvi B

Reputation: 1567

Since the jar is not under web-inf folder you are seeing this error. There are several ways to resolve this issue

  1. add below profile

    <profile>
          <id>qa</id>
          <build>
            <plugins>
              <plugin>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                  <execution>
                    <phase>install</phase>
                    <goals>
                      <goal>copy-dependencies</goal>
                    </goals>
                    <configuration>
                      <outputDirectory>${project.build.directory}/lib</outputDirectory>
                    </configuration>
                  </execution>
                </executions>
              </plugin>
            </plugins>
          </build>
        </profile>
    
  2. Dependencies directory created in target folder

      mvn install dependency:copy-dependencies 
    

Upvotes: 0

Related Questions