Reputation: 2923
I have installed Maven and created a simple project according to their instructions. I then added the spring-context (per the Spring IO site) dependency. Nothing interesting happens.
{rant} I HATE that Spring is shoving Maven down my throat! Maven is TERRIBLE in established shops that can't stop what they are doing to Maven-ize hundreds of artifacts. On top of that, Spring has now fragmented the dependencies in incomprehensible ways. Stupid! {/rant}
I assume there is some way to simply download all the JAR in a dependency. Can anyone provide a pom.xml and a command line that starts with "mvn"?
Upvotes: 0
Views: 6332
Reputation: 2923
I accepted Ralph's answer, but I wanted to record the steps I took to do the full task. Just to clarify, I don't have a problem with Maven. I have a BIG problem with Spring forcing me to use it.
Download Maven, unzip it. Note that it requires M2_HOME and JAVA_HOME properties, which can be set in a CMD file if you don't want to make them permanent.
Run this command to create a default project, with a pom.xml. Note that you should be in an empty folder when you do it.
mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
Move into the my-app folder that was just created and edit the pom.xml. Note that Maven seems to require a JUnit dependency for testing.
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>my-app</name>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>3.2.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.2.2.RELEASE</version>
</dependency>
</dependencies>
Run
mvn dependency:copy-dependencies
and your project should now have a dependencies folder with all the JAR.
Upvotes: 0
Reputation: 120871
When you have all dependencies defined, then you only need to run mvn dependency:copy-dependencies
, then maven ({rant} the great tool{/rant}) will put all dependencies including transitive dependencies to the target/dependencies
folder
@See: http://maven.apache.org/plugins/maven-dependency-plugin/copy-dependencies-mojo.html
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<groupId>com.test</groupId>
<artifactId>com.test</artifactId>
<properties>
<spring.version>3.2.2.RELEASE</spring.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
</dependencies>
</project>
Upvotes: 1
Reputation: 21390
This is how you add the Spring context dependency to your project.
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.2.2.RELEASE</version>
</dependency>
Now it depends exactly what you want. Whatever mvn command you run the dependencies will be first downloaded to your Maven local repository, not your project.
Here you can also download the jar http://search.maven.org/#browse|-618956366, but it's not the recommended way.
Alternatively, you can clear your entire Maven local repository and then after a command like mvn package
or mvn install
it will be repopulated again with all your dependencies. If it's a web application your war will contain in WEB-INF/lib
all the dependencies. If you want to create a jar with all dependencies see How can I create an executable JAR with dependencies using Maven?.
Upvotes: 0