Where to put java libraries for maven project?

I found that Maven implies a specific directory layout. But I don't understand from here: http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html where the Java libraries needed to compile and run my code should be placed. I think they cannot be placed under "src / main / resources" because resources are something like images or something. They also don't seem to fit under "src / main / java". If I wasn't using maven, I would place the libraries in the root of the project lib

. But I don't think it would be correct for a maven project. Please advise.

UPD: I solved the problem. The thing is, I installed packages for my sources as src.main.myApp instead of main.myApp. This seems to upset maven.

+3


source to share


2 answers


Maven manages your project dependencies differently in a standard Java project.

You declare the libraries you depend on in the pom.xml project:

eg.



<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>your-project</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>

    <name>your-project-web</name>

    <dependencies>
        <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-mapper-asl</artifactId>
            <version>1.8.5</version>
        </dependency>
    </dependencies>     
</project>

      

When you use maven command to create a project i.e. mvn install

, it downloads the dependencies for you and stores them in your local repository.

+3


source


In Maven, you don't store libraries in your project. You define dependencies on these libs and they are populated into your local repository. At build time, if you package libraries (say for a war file), they end up in the // WEB -INF / lib target. But in general, the whole idea is not to deal with or manage these libraries, just to manage the dependencies in your pom file and forget everything else.



+2


source







All Articles