Aliaksei Bulhak
Aliaksei Bulhak

Reputation: 6208

Maven don't add libraries

I use eclipse and Apachw Maven. I install maven plugin for eclipse. And have project. I add some dependencies for servlet-api into my pom file you can see them :

<dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>jsp-api</artifactId>
            <version>2.1</version>
        </dependency>

        <dependency>
            <groupId>org.glassfish.web</groupId>
            <artifactId>jstl-impl</artifactId>
            <version>1.2</version>
        </dependency>

        <dependency>
            <groupId>javax.servlet.jsp.jstl</groupId>
            <artifactId>jstl-api</artifactId>
            <version>1.2</version>
        </dependency>

I refresh my project, make maven clean and then package but in result I get this:

enter image description here

so mabe someone can help me? (I can download and add all this libraries in web-inf/lib folder but I don't wan do this)

UPDATE

enter image description here

Upvotes: 1

Views: 2432

Answers (3)

alex.p
alex.p

Reputation: 2739

Try running mvn eclipse:eclipse on your project, this will create the .classpath and .project files for your project. You'll also need to rebuild your project in Eclipse by doing Project -> Clean

The problem you're having is that the libraries aren't in your .classpath, running eclipse:eclipse should sort this.

.classpath and .project are Eclipse specific files that hold metadata about the project. The .classpath in particular points to where relevant classes are.

See http://maven.apache.org/plugins/maven-eclipse-plugin/eclipse-mojo.html for more info.

Upvotes: 1

Ale Zalazar
Ale Zalazar

Reputation: 1980

According to the image with the Libraries tab you posted, the project isn't imported as Maven Project, and looks more like a Eclipse Project (Dynamic Web Project), because it doesn't have a "Maven Dependencies" entry.

In this case you can re-import your project with Existing Maven Projects option (not Existing Projects into Workspace) or ...

You can leave it as it is and "Add Library" > "Server runtime" and pick some server instance.

Upvotes: 2

Alexis Dufrenoy
Alexis Dufrenoy

Reputation: 11946

Using a Maven project in Eclipse can be a bit tricky. You can try the following steps:

  • Build you maven project by command line: in your project folder, type mvn clean install
  • When the project is successfully built, refresh your project in Eclipse
  • Clean your project in Eclipse, in order to rebuild your workspace

Upvotes: 1

Related Questions