Where can I download Spring Framework jars without using Maven? - java

This question's answers are a community effort. Edit existing answers to improve this post. It is not currently accepting new answers or interactions.
SpringSource.org changed their site to http://spring.io
Does someone know how to get the latest build without Maven/github? from http://spring.io/projects

Please edit to keep this list of mirrors current
I found this maven repo where you could download from directly a zip file containing all the jars you need.
https://maven.springframework.org/release/org/springframework/spring/
https://repo.spring.io/release/org/springframework/spring/
Alternate solution: Maven
The solution I prefer is using Maven, it is easy and you don't have to download each jar alone. You can do it with the following steps:
Create an empty folder anywhere with any name you prefer, for example spring-source
Create a new file named pom.xml
Copy the xml below into this file
Open the spring-source folder in your console
Run mvn install
After download finished, you'll find spring jars in /spring-source/target/dependencies
<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>spring-source-download</groupId>
<artifactId>SpringDependencies</artifactId>
<version>1.0</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.2.4.RELEASE</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<executions>
<execution>
<id>download-dependencies</id>
<phase>generate-resources</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/dependencies</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Also, if you need to download any other spring project, just copy the dependency configuration from its corresponding web page.
For example, if you want to download Spring Web Flow jars, go to its web page, and add its dependency configuration to the pom.xml dependencies, then run mvn install again.
<dependency>
<groupId>org.springframework.webflow</groupId>
<artifactId>spring-webflow</artifactId>
<version>2.3.2.RELEASE</version>
</dependency>

Related

how to compile spring-boot-maven-plugin without dependencies?

I am trying to do an excercise with micro-services in Java with Spring boot, for this I am developing two web services in different projects with the intention of deploying them in tomcat like two independent files (.war).
I have read about set up tomcat to have the dependencies in an specified folder to share it with other services and this way not to increase the same libraries in all services.
The ploblem is that when I compiled the service with maven through the artifact spring-boot-maven-plugin the .war files always has the dependencies inside. Because of I want to know if someone know how to configure maven to
remove dependencies from .war file..... in Spring Boot.
The .war follows with the dependencies inside, Edited:
I have added the provided like said Michael Potter and the execution. it works fine. My pom.xml is the follow:
<?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.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>demo1</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.4.RELEASE</version>
<relativePath/>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<skip>true</skip>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
For Maven not to include dependency in your WAR file you need to specify its scope to provided. The description of the scope from official Maven documentation:
This is much like compile, but indicates you expect the JDK or a
container to provide the dependency at runtime. For example, when
building a web application for the Java Enterprise Edition, you would
set the dependency on the Servlet API and related Java EE APIs to
scope provided because the web container provides those classes. This
scope is only available on the compilation and test classpath, and is
not transitive.
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.192</version>
<scope>provided</scope>
</dependency>
The dependency will be downloaded to compile the sources, but not packed in the WAR.
Concerning spring-boot-maven-plugin. By default it makes repackaging of a WAR that allows you to launch it from console. Thus, it packages all required dependencies to the archive - even with the provided scope. You can see in your target directory two files: {project-name}.war which is repackaged and {project-name}.war.original - the one that should not contain provided dependencies. To disable repackaging you should change spring-boot-maven-plugin configuration to the following:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<skip>true</skip>
</configuration>
</execution>
</executions>
</plugin>
Then you need to place the required dependency to tomcat/lib folder and restart the Tomcat.

Create Parent Maven Project from Existing projects

I have existing two maven projects, I want to combine them after build into one project.
I have not created these projects module wise, the two projects are separate maven projects.
Below is the POM xml code part from existing projects.
Project One pom.xml
<groupId>com.olex</groupId>
<artifactId>olex-reg</artifactId>
<version>1.0</version>
<packaging>war</packaging>
Project Two pom.xml
<groupId>com.olex</groupId>
<artifactId>olex-qba</artifactId>
<version>1.0</version>
<packaging>war</packaging>
Combine Project pom.xml
<groupId>com.olex</groupId>
<artifactId>olex-war</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
I want to combine these projects into one like olex-war, A complete project.
After build I want all the code to be copied to this olex-war project.
Please suggest / provide hint if anyone aware of such scenario.
Thanks in advance.
You could start with a pom like this, that extract all the content of your old war files into content directory. Then you could package everything in that directory (except for web.xml and other metadata) in your new war.
<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.olex</groupId>
<artifactId>olex-war</artifactId>
<packaging>war</packaging>
<version>1.0</version>
<name>olex-war Maven Webapp</name>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>olex-war</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>unpack</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.olex</groupId>
<artifactId>olex-qba</artifactId>
<version>${project.version}</version>
<packaging>war</packaging>
</artifactItem>
<artifactItem>
<groupId>com.olex</groupId>
<artifactId>olex-reg</artifactId>
<version>${project.version}</version>
<packaging>war</packaging>
</artifactItem>
</artifactItems>
<excludes>WEB-INF/web.xml</excludes>
<includes>**/*.class, **/*.jar, **/*.properties</includes>
<outputDirectory>${project.build.directory}/content</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
You should combine your projects manually. Many elements (like config files) need manual merging anyway and you want to avoid to accidentally loose something from one project because the other overwrites it quietly.
This would be a horrible mind-dulling task if there were not Version Control Systems to help you with the merging.
First set up a version control system (VCS). It will help in many other situations as well. I recommend git, but if you have another already up and running that should do it just fine, I won't use any fancy specials here.
Then create an empty folder for the new project and copy all the data from the first project into it. Do all replacements as you see fit (web.xml, pom.xml, other config files) and commit it to the VCS.
This will write this version of all files into the VCS and you cannot loose them again, so if you happen to make a mistake, no worries, just revert all changes back to this point.
Then copy the content of the second project over it overwriting everything thats duplicate.
Now you can use the "show differences" feature of your VCS to see what you'll need to merge. Most likely you can do so in a graphic tool so that makes it easy.
Most of them will be "unknown" that is, the new file does not exist in the VCS, yet. Most likely you can just add them to the VCS and be done with them.
More interesting are the ones that are "modified". That means the file already existed and the other project contained them as well. You will have to merge them into a combined version that is from now on valid for your new project.
When you are done you should have all the files (including pom.xml) necessary for the new project ready. Commit them to the VCS to not loose this state in the future.

org.codehaus.cargo.container.ContainerException: Cannot create deployable

In maven pom file, my project packaging type is "jar" like bellow.
<packaging>jar</packaging>
My cargo-maven2-plugin configuration in pom.xml file from the legacy code. I try to run it Eclipse Kelpler, but since the plugin configuration didn't mention cargo-maven2-plugin version(I don't know actual version for this configuration), Eclipse try to get the most recent one which is 1.4.8. Based on the configuration, the Tomcat version looks like 6.0.14, but container id is 5x. Whole configuration seems doesn't right and I try to make it work. Any suggestions? The package type must jar and I can't change it.
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<configuration>
<wait>${cargo.wait}</wait>
<container>
<containerId>tomcat5x</containerId>
<zipUrlInstaller>
<url>
http://archive.apache.org/dist/tomcat/tomcat-6/v${tomcat.version}/bin/apache-tomcat-${tomcat.version}.zip
</url>
<installDir>${installDir}</installDir>
</zipUrlInstaller>
</container>
<configuration>
<home>${project.build.directory}/tomcat5x/container</home>
<properties>
<cargo.hostname>${cargo.host}</cargo.hostname>
<cargo.servlet.port>${cargo.port}</cargo.servlet.port>
</properties>
<deployables>
<deployable>
<properties>
<context>ROOT</context>
</properties>
</deployable>
</deployables>
</configuration>
</configuration>
<executions>
<execution>
<id>start-container</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>stop-container</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<properties>
<cargo.host>localhost</cargo.host>
<cargo.port>25888</cargo.port>
<cargo.wait>false</cargo.wait>
<tomcat.version>6.0.14</tomcat.version>
</properties>
I set type for to "jar" to match project. But when I run maven build in Eclipse Kelper, I am getting following error message. As you can see there is no allowed type "jar" is listed. Could any one help?
org.codehaus.cargo.container.ContainerException: Cannot create deployable. There's no registered deployable for the parameters (container [id = [default]], deployable type [jar]). Valid types for this deployable are:
- ear
- war
- rar
- bundle
- file
- sar
- ejb
According to Cargo's Tomcat 5.x doc only war files can be deployed to tomcat, that's why it is failing. Why don't you use war to create a webapp? I don't know your requirements, but usually if you deploy on Tomcat you have a webapp in a war file. What do you need to do? Do you have a servlet or jsp file in your project? Do you need it to use it as a library for an other webapp?
You could create a web app and include the jar generated by that project as a dependency. Use org.apache.marmotta:marmotta-archetype-webapp Maven archetype to create your project and add your legacy project dependency to the pom, it would be something like this:
<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>test.war</groupId>
<artifactId>test-war</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>test-war Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>test-war</finalName>
</build>
<dependencies>
<dependency>
<groupId>legacyProjectGroupId</groupId>
<artifactId>legacyProjectArtifactId</artifactId>
<version>legacyProjectVersion</version>
</dependency>
</dependencies>
</project>

How to unpack view resources for JBehave from Maven (jar libraries) in IntelliJ Idea?

I'm doing project with JBehave and want my reports to be pretty. Here I've read that I can use the unpack-view-resources goal. The problem is following: I use IntelliJ Idea and I used File->Project Structure->Libraries to add the project From Maven. So, I have .jar files but don't have access to pol.xml (I don't see this file at all).
Where I should create it? Or how I have to setup JBehave to have an ability to use pol.xml for view resources unpacking?
Maybe there is another solution for this problem, or download all .css and .js files by myself is the only way in my case?
SOLUTION:
I only had to right mouse click on the project name (the root folder) and choose "Add Framework Support...". Than I have a pom.xml file.
I used this example, so it looks like:
<?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.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>myGroup</groupId>
<artifactId>myArtifact</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.jbehave</groupId>
<artifactId>jbehave-core</artifactId>
<version>3.8</version>
<classifier>resources</classifier>
<type>zip</type>
</dependency>
<dependency>
<groupId>org.jbehave.site</groupId>
<artifactId>jbehave-site-resources</artifactId>
<version>3.1.1</version>
<type>zip</type>
</dependency>
<dependency>
<groupId>org.jbehave</groupId>
<artifactId>jbehave-core</artifactId>
<version>3.8</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.jbehave</groupId>
<artifactId>jbehave-maven-plugin</artifactId>
<version>3.8</version>
<executions>
<execution>
<id>unpack-view-resources</id>
<phase>process-resources</phase>
<goals>
<goal>unpack-view-resources</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Than I use Maven panel (on the right of the IntelliJ window, as Engineer Dollery said) called "Maven Projects" and see there my project. I expand it, there I see Lifecycle and expand it too, than I choose "install" and click "run" (green arrow on the top of the panel) and I have all needed files unpacked.
First, You shouldn't be adding libraries to the project manually -- that's what maven is for, so start by deleting the one's you've added. The maven panel, usually on the right of the intellij window should have a tree that can expand to show Lifecycle and Plugins -- it is here that you should find the maven goal you describe. If not, you can run any maven goal through editing run configurations from the toolbar, adding a new maven run config and stating your goals there.
Good luck and let us know how it goes.

How to set up a minimal Maven pom.xml file for a Heroku worker process in Java?

First off: I'm not a Java coder. I'm new to the Java/Maven tool chain. We're using a Java library for a project which we want to launch as a Heroku background worker.
This project relies on two external libraries, the mongodb Java driver which is available through Maven's central repo, and another third party library. I've seen the Heroku article on "unmanaged dependencies", but something else appears missing, as I get an error like: Could not find the main class: com.company.myproject.MyApp Program will exit. when I try to run the app locally according to Heroku's instructions on "Getting Started with Java".
I noticed that their pom.xml file contains a Maven plugin maven-dependency-plugin to copy dependencies, and when I check my target/classes folder, I don't see any of the dependencies.
Heroku also publishes a guide on building background workers in Java. That pom.xml contains a build assembly plugin, which seems more complex.
I'm a bit lost in all this ceremony (especially coming from Rails), and I'd like to stat with the simplest possible pom.xml to get this running. Is there a Maven archetype file for Java workers on Heroku? I'm also using NetBeans as IDE, and it would be great to use the IDE tools for this, if available, but it's a secondary priority.
Below my pom.xml so far:
<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>com.myproject</groupId>
<artifactId>myproject</artifactId>
<version>0.1</version>
<packaging>jar</packaging>
<name>myproject</name>
<url>http://maven.apache.org</url>
<properties>
<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>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>2.7.3</version>
</dependency>
<dependency>
<groupId>org.thirdparty</groupId>
<artifactId>thirdparty</artifactId>
<version>0.2.9</version>
<scope>provided</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>project-local</id>
<name>Project-local Repo</name>
<url>file:${project.basedir}/repo</url>
</repository>
</repositories>
</project>
You definitely need to use the maven-dependency-plugin to copy all of the dependencies into the target/dependency directory:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals><goal>copy-dependencies</goal></goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Then your Procfile needs to include those dependencies in the classpath:
foo: java -cp target/classes:target/dependency/* com.myproject.Main
Where com.myproject.Main is the class name of the Java class you want to run (which must contain a public static void main method. Note that this also adds the Java classes which are compiled from src/main/java into the target/classes dir.

Categories

Resources