Reputation: 10161
I found that Maven implies specific directory layout. But I don't understand from here: http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html
where java libraries needed to compile and run my code should be placed. I think they shouldn't be placed under 'src/main/resources' because resources is something like images or so. Also it doesn't look right to place them under 'src/main/java'. If I wouldn't use maven, I'd place libraries in project's root lib
directory. But I don't think that for maven project it will be right. Please advise.
UPD: I solved the problem. The matter was that I set packages for my sources as src.main.myApp instead of main.myApp. This seems to upset maven.
Upvotes: 5
Views: 4795
Reputation: 1685
In Maven, you do not keep libraries in your project. You specify dependencies on these libs, and they get populated into your local repository. At the time of build, if you are packaging the libs (say for a war file), they do get pulled into target//WEB-INF/lib. But in general, the whole idea is not to deal with these libraries or manage them, just to manage dependencies in your pom file, and forget the rest.
Upvotes: 1
Reputation: 4219
Maven handles your project dependencies in a different way to a 'Standard' Java project.
You declare the libraries you depend on in your project's pom.xml:
e.g.
<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 a maven command to build the project, i.e. mvn install
, it will download the dependencies for you and store them in your local repository.
Upvotes: 3