yasin
yasin

Reputation: 49

Missing Maven Dependency and can not import class

I have created a new maven project by choosing org.apache.maven.archtypes maven.archtype.webapp.

I perform the below commands:

but maven dependency library is not added into libraries folder although a build success message has been output.

[INFO] Scanning for projects...
<p> 
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO] BUILD SUCCESS
[INFO] Total time: 2.248 s
[INFO] Finished at: 2018-06-07T09:40:57+03:00
[INFO] Final Memory: 8M/20M

Here's my pom file, e.g dependency mvnrepository.com/artifact/com.fasterxml.jackson.datatype/jackson-datatype-

<?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.0http://maven.apache. rg/xsd/maven-4.0.0.xsd">

    <groupId>test</groupId>
    <artifactId>maven.test</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>maven.test Maven Webapp</name>
    <!-- FIXME change it to the project's website -->
    <url>http://www.example.com</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.7</maven.compiler.source>
        <maven.compiler.target>1.7</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>


    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>

        <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.datatype/jackson-datatype-jsr310 -->
        <dependency>
            <groupId>com.fasterxml.jackson.datatype</groupId>
            <artifactId>jackson-datatype-jsr310</artifactId>
            <version>2.9.5</version>
        </dependency>

        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.16</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
</project>

Here's my library screenshot without maven dependency

library without maven dependency

Upvotes: 0

Views: 11313

Answers (4)

Frank
Frank

Reputation: 298

go to the source folder of the project using cmd and run maven command: mvn clean install (this command won't work unless you specified path to maven/bin folder in path of system variables) be sure you're not beyond the proxy, if you are, then you should configure maven to work with it. Link to how to configure a proxy in maven

Upvotes: 0

Amol shinde
Amol shinde

Reputation: 49

I saw screen shot you attached but there is not any folder called "Maven Dependencies". So please try one option it may solve your problem...right click on project -> configure -> convert to maven.

Upvotes: 0

TheSprinter
TheSprinter

Reputation: 1528

As Amer mentioned , do a maven update for your project, if it doest work the try with different network(either use mobile phone network or home network) to update project then
do a eclipse clean(not maven clean) for that project then do a
maven install.
sometimes network block the jar file to download

Upvotes: 1

Amer Qarabsa
Amer Qarabsa

Reputation: 6574

right click on the project -> maven -> update project

Upvotes: 0

Related Questions