spring frameworkのjarダウンロード(取得方法)
次に個人的に作ろうとしたものがあって、アプリとサーバーとの通信があったりしていつも使っているWicketだとやっぱ使いづらい部分があったりするんだよね・・と言うことで、会社の別のプロジェクトでも使っていて指くわえてみていたspring frameworkをつかってみようかと思いjarファイルなんぞをダウンロードなんて思いながら公式を見てみると・・・
The recommended way to get started using spring-framework in your project is with a dependency management system – the snippet below can be copied and pasted into your build. Need help? See our getting started guides on building with Maven and Gradle.
http://projects.spring.io/spring-framework/#quick-start:tite
うへ!jar単体ではダウンロードできないみたい。MavenかGradleをお勧めしますよ!キリ!なんて言われてしまった。SierなんてANT鉄板なんすよ!ANT(あんた)ねーーこれどうしてくれんのよ!!と逆切れしながら、jar(じゃぁ)どうしよう!なんて思いつつ泣きながらまた検索するわけですよ、、40にして泣くんですよ、ディスプレイが曇って見えませんよ・・いましたいました。僕みたいな迷える子羊が。
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:
java - Where can I download Spring Framework jars without using Maven? - Stack Overflow
1.Create an empty folder in anywhere with any name you prefer, for example spring-source
2.Create a new file named pom.xml
3.Copy the following in this file
4.Open the spring-source folder in your console
5.Run mvn install
6.After download finished, you'll find spring jars in /spring-source/target/dependencies
さすがはstackoverflow、僕みたいなほんと初心者でも親切に答えてくれる人がいる!泣きながら試しましたよ。以下上記のURLをなぞったものです。あと、Mavenへのパスぐらいは通しておいてください。
3.pom.xmlを書く
わかんないけどpom.xmlに以下のXML文書を書くわけですよ。ほんと分からん
<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>
5.Mavenでインストール
次のコマンドを打つと何やら始まります。自分には何のことやらさっぱりわかりません
mvn install
※ これを実行するにはMavenへパスが通っていることが前提です。お気を付けを・・・
じゃぁほかのライブラリは?
先のスタックオーバーフローでは、ほかの例として「Spring Web Flow」のjarをダウンロードする方法も書いています。次のXMLエレメントを入れるんだと・・・
<dependency>
<groupId>org.springframework.webflow</groupId>
<artifactId>spring-webflow</artifactId>
<version>2.3.2.RELEASE</version>
</dependency>こんな風らしい・・・<dependencys>タグに先のエレメントを追加すればいいみたい。
<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>
<!-- Spring Web Flowの何か -->
<dependency>
<groupId>org.springframework.webflow</groupId>
<artifactId>spring-webflow</artifactId>
<version>2.3.2.RELEASE</version>
</dependency>
<!-- Spring Web Flowの何か -->
<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>そしてもう一度Mavenの次の謎コマンド・・・
mvn install
※ これを実行するにはMavenへパスが通っていることが前提です。お気を付けを・・・
ほら、、取れた。なんか追加された・・こんな風にして任意のjarファイルを取るみたい。






