サンプル集 |
■VC ■C# ■Java ■BorlandC ■LinuxC ■MS-DOS ■bash ■Excel VBA ■VBScript ■PHP ■HTML ■perl ■iPhone ■Android ■Lua ■other |
Linuxコマンド |
用語集 |
debian メモ |
apache2 メモ |
MySQL メモ |
Oracle メモ |
HOME |
サンプルプロジェクトを作ってみます。
◆環境OS | Windows 10 Home 64bit |
---|---|
maven | 3.3.9 |
作成方法は以前のバージョンと同じ手順で行ってみます。
以前のバージョンの手順 >>> maven
mavenを実行するとダウンロード後のビルドでエラーが出ました。
hetypeArtifactId=maven-archetype-webapp
[INFO] Scanning for projects...
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plug
ins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugi
ns/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom (4 KB at 1.1 KB/
sec)
:
略
:
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plug
ins/maven-archetype-plugin/2.4/maven-archetype-plugin-2.4.jar
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugi
ns/maven-archetype-plugin/2.4/maven-archetype-plugin-2.4.jar (92 KB a
t 214.2 KB/sec)
[INFO]
[INFO] ----------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ----------------------------------------------------------------
[INFO]
[INFO] --- maven-archetype-plugin:2.4:create (default-cli) @ standalone
-pom ---
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/arch
etype/archetype-catalog/2.4/archetype-catalog-2.4.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/arche
type/archetype-catalog/2.4/archetype-catalog-2.4.pom (2 KB at 6.2 KB/
sec)
:
略
:
Downloaded: https://repo.maven.apache.org/maven2/org/apache/ant/ant/1.8
.1/ant-1.8.1.jar (1479 KB at 220.6 KB/sec)
[INFO] ----------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ----------------------------------------------------------------
[INFO] Total time: 01:06 min
[INFO] Finished at: 2017-01-07T11:59:07+09:00
[INFO] Final Memory: 14M/50M
[INFO] ----------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype
-plugin:2.4:create (default-cli) on project standalone-pom: Unable to
parse configuration of mojo org.apache.maven.plugins:maven-archetype
-plugin:2.4:create for parameter #: Cannot create instance of interfa
ce org.apache.maven.artifact.repository.ArtifactRepository: org.apach
e.maven.artifact.repository.ArtifactRepository.
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with th
e -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, p
lease read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/Plugi
nConfigurationException
エラーメッセージを眺めてみます。
2.4:create (default-cli) on project standalone-pom
standalone-pomプロジェクトのゴールorg.apache.maven.plugins:maven-archetype-plugin:2.4:createの実行に失敗しました。
chetype-plugin:2.4:create for parameter #:
パラメーター#のmojo org.apache.maven.pluging:maven-archetype-plugin:2.4:createの設定を解析できません。
y.ArtifactRepository:
インターフェースorg.apache.maven.artiface.repository.ArtifactRep
ositoryのインスタンスを作成できません。
tch.
エラーの完全なスタック・トレースを表示するには、-eスイッチを使用してmavenを再実行します。
完全なデバッグログを有効にするには、-Xスイッチを使用してmavenを再実行します。
ad the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginConfigu
rationException
エラーと解決策の情報については、以下の記事を読んでください。
表示されたURLにアクセスしましたが、「ページがありません」となってしまいました。
full stack traceを見るには-eスイッチを付けてくださいと出ているので、-eを付けて実行してみます。
hetypeArtifactId=maven-archetype-webapp -e
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ----------------------------------------------------------------
[INFO]
[INFO] --- maven-archetype-plugin:2.4:create (default-cli) @ standalone
-pom ---
[INFO] ----------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ----------------------------------------------------------------
[INFO] Total time: 1.817 s
[INFO] Finished at: 2017-01-07T13:35:26+09:00
[INFO] Final Memory: 14M/114M
[INFO] ----------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype
-plugin:2.4:create (default-cli) on project standalone-pom: Unable to
parse configuration of mojo org.apache.maven.plugins:maven-archetype
-plugin:2.4:create for parameter #: Cannot create instance of interfa
ce org.apache.maven.artifact.repository.ArtifactRepository: org.apach
e.maven.artifact.repository.ArtifactRepository.
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execu
te goal org.apache.maven.plugins:maven-archetype-plugin:2.4:create (d
efault-cli) on project standalone-pom: Unable to parse configuration
of mojo org.apache.maven.plugins:maven-archetype-plugin:2.4:create fo
r parameter #: Cannot create instance of interface org.apache.maven.a
rtifact.repository.ArtifactRepository
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(M
ojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(M
ojoExecutor.java:153)
:
略
:
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, p
lease read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/Plugi
nConfigurationException
org.apache.maven.lifecycle.LifecycleExecutionExceptionが出ています。
参照さきのURLが先ほどのとは違うものが出ています。 そのURLにアクセスすると以下のページが表示されました。
この問題は、プライグインのゴールの設定ができない場合です。
on for the plugin in your POM does not match the parameter types of t
he goal in question.
最も可能性の高い原因は、POMプラグインの「設定」セクションの内容が問題のゴールのパラメータータイプと一致しない。
r this error.
例えば、文字列から数値パラメータを設定しようとすると、このエラーが発生する。
ulting the plugin documentation.
そのため、プラグインマニュアルを参照し、ゴールの設定が正しいことを確認してください。
plugin index.
多くの一般的なMavenプラグインのドキュメントは、プラグインのインデックスから入手できます。
igured because of a broken plugin class path.
まれに、プラグインクラスパスが壊れているため、ゴールを設定できない可能性もある。
the plugin, this can result in linkage errors that prevent the config
uration of the goal.
たとえば、プラグインクラスパスにプラグインの依存関係がない場合、リンケージエラーが発生し、ゴールの設定が妨げられている可能性があります。
cal repository which is usually located at ${user.home}/.m2/repositor
y.
プラグインJARとそのPOMが損なわれているかどうかを確認するには、通常は${user.home}/.m2/repositorにあるローカル・リポジトリを調べます。
the file to check is com/company/custom-maven-plugin/1.0/custom-maven
-plugin-1.0.jar and custom-maven-plugin-1.0.pom, respectively.
com.company:custom-maven-plugin:1.0という座標(coordinates)のプラグインの場合、チェックするファイルはそれぞれ
(1) com/company/custom-maven-plugin/1.0/custom-maven-plugin-1.0.jar
(2) custom-maven-plugin-1.0.pom
です。
noticeable by checksum mismatches, simply delete the local files and
have Maven re-download it.
これらのファイルがプラグインリポジトリーと一致しない場合、例えば、チェックサムの不一致などのように、ローカルファイルを削除しMavenに再ダウンロードさせるだけです。
M in the plugin repository are byterise identical but Maven still rep
orts a linkage error, please report this to the maintainer of the plu
gin.
プラグインリポジトリのJAR/POMとJAR/POMのローカルコピーが同一である場合、Mavenが依然としてリンケージエラーを報告している事を確認した場合は、これをプラグインのメンテナーに報告してください。
ERRORで表示されているgoalは org.apache.maven.plugins:maven-archetype-plugin:2.4:create (default-cli) なので以下のファイルを確認します。
- org/apache/maven/plugin/maven-archetype-plugin/2.4/maven-archetype-plugin.jar
- maven-archetype-plugin-2.4.pom
${user.home}/.m2/repositor配下には上記の2つのファイルはありました。
「ローカルコピーと同一であるか」確認するような感じの事が書いてありました。 mavenが成功するとフォルダが作成されてその中にPOMなど生成されると思っています。 そのため、maven実行前にはローカルにはPOMはありませんので何と比較すれば良いのか分かりません。
もしかしたらPOMを作っておかなければならないのかもしれません。
「POMを生成したい場合、archetypeにgenerateを指定する」という記載を見たので試してみます。
rchetypeArtifactId=maven-archetype-webapp
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ----------------------------------------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:2.4:generate (default-cli) > generate
-sources @ standalone-pom >>>
[INFO]
[INFO] <<< maven-archetype-plugin:2.4:generate (default-cli) < generate
-sources @ standalone-pom <<<
[INFO]
[INFO] --- maven-archetype-plugin:2.4:generate (default-cli) @ standalo
ne-pom ---
[INFO] Generating project in Interactive mode
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/arch
etypes/maven-archetype-webapp/1.0/maven-archetype-webapp-1.0.jar
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/arche
types/maven-archetype-webapp/1.0/maven-archetype-webapp-1.0.jar (4 KB
at 2.8 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/arch
etypes/maven-archetype-webapp/1.0/maven-archetype-webapp-1.0.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/arche
types/maven-archetype-webapp/1.0/maven-archetype-webapp-1.0.pom (533
B at 1.8 KB/sec)
[INFO] Using property: groupId = jp.test
[INFO] Using property: artifactId = mvn-test
Define value for property 'version': 1.0-SNAPSHOT: : (enter)
[INFO] Using property: package = jp.test
Confirm properties configuration:
groupId: jp.test
artifactId: mvn-test
version: 1.0-SNAPSHOT
package: jp.test
Y: : (enter)
[INFO] ----------------------------------------------------------------
[INFO] Using following parameters for creating project from Old (1.x) A
rchetype: maven-archetype-webapp:1.0
[INFO] ----------------------------------------------------------------
[INFO] Parameter: basedir, Value: C:\
[INFO] Parameter: package, Value: jp.test
[INFO] Parameter: groupId, Value: jp.test
[INFO] Parameter: artifactId, Value: mvn-test
[INFO] Parameter: packageName, Value: jp.test
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] project created from Old (1.x) Archetype in dir: C:\mvn-test
[INFO] ----------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ----------------------------------------------------------------
[INFO] Total time: 01:01 min
[INFO] Finished at: 2017-01-09T00:16:01+09:00
[INFO] Final Memory: 16M/148M
[INFO] ----------------------------------------------------------------
SUCCESSになりました! 途中で2回入力待ちになりましたが、何も入力せずにenterで進めました。
生成されたフォルダの内容を確認します。
フォルダー パスの一覧: ボリューム OS
ボリューム シリアル番号は 0045-5657 です
C:\MVN-TEST
│ pom.xml
└─src
└─main
├─resources
└─webapp
│ index.jsp
└─WEB-INF
web.xml
スカスカな気がしますが、packageしてみます。
C:\mvn-test> mvn package
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------------------------------------------------
[INFO] Building mvn-test Maven Webapp 1.0-SNAPSHOT
[INFO] ----------------------------------------------------------------
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plug
ins/maven-resources-plugin/2.6/maven-resources-plugin-2.6.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugi
ns/maven-resources-plugin/2.6/maven-resources-plugin-2.6.pom (8 KB at
4.8 KB/sec)
:
略
:
Downloading: https://repo.maven.apache.org/maven2/junit/junit/3.8.1/jun
it-3.8.1.jar
Downloaded: https://repo.maven.apache.org/maven2/junit/junit/3.8.1/juni
t-3.8.1.jar (119 KB at 197.4 KB/sec)
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ m
vn-test ---
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/mave
n-plugin-api/2.0.6/maven-plugin-api-2.0.6.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/maven
-plugin-api/2.0.6/maven-plugin-api-2.0.6.pom (2 KB at 4.9 KB/sec)
:
略
:
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/share
d/maven-filtering/1.1/maven-filtering-1.1.jar (43 KB at 17.0 KB/sec)
Downloaded: https://repo.maven.apache.org/maven2/org/codehaus/plexus/pl
exus-utils/2.0.5/plexus-utils-2.0.5.jar (218 KB at 81.1 KB/sec)
[WARNING] Using platform encoding (MS932 actually) to copy filtered res
ources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ mvn-te
st ---
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/mave
n-plugin-api/2.0.9/maven-plugin-api-2.0.9.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/maven
-plugin-api/2.0.9/maven-plugin-api-2.0.9.pom (2 KB at 4.9 KB/sec)
:
略
:
Downloaded: https://repo.maven.apache.org/maven2/commons-logging/common
s-logging-api/1.1/commons-logging-api-1.1.jar (44 KB at 16.3 KB/sec)
Downloaded: https://repo.maven.apache.org/maven2/junit/junit/3.8.2/juni
t-3.8.2.jar (118 KB at 39.2 KB/sec)
[INFO] No sources to compile
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResour
ces) @ mvn-test ---
[WARNING] Using platform encoding (MS932 actually) to copy filtered res
ources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\mvn-test\src\test\resourc
es
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile)
@ mvn-test ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ mvn-test
---
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/sure
fire/surefire-booter/2.12.4/surefire-booter-2.12.4.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/suref
ire/surefire-booter/2.12.4/surefire-booter-2.12.4.pom (3 KB at 10.1 K
B/sec)
:
略
:
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugi
n-tools/maven-plugin-annotations/3.1/maven-plugin-annotations-3.1.jar
(14 KB at 14.0 KB/sec)
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/maven
-toolchain/2.0.9/maven-toolchain-2.0.9.jar (38 KB at 31.9 KB/sec)
[INFO] No tests to run.
[INFO]
[INFO] --- maven-war-plugin:2.2:war (default-war) @ mvn-test ---
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/mave
n-archiver/2.5/maven-archiver-2.5.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/maven
-archiver/2.5/maven-archiver-2.5.pom (5 KB at 14.8 KB/sec)
:
略
:
Downloaded: https://repo.maven.apache.org/maven2/xpp3/xpp3_min/1.1.4c/x
pp3_min-1.1.4c.jar (25 KB at 34.8 KB/sec)
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/share
d/maven-filtering/1.0-beta-2/maven-filtering-1.0-beta-2.jar (33 KB at
36.6 KB/sec)
[INFO] Packaging webapp
[INFO] Assembling webapp [mvn-test] in [C:\mvn-test\target\mvn-test]
[INFO] Processing war project
[INFO] Copying webapp resources [C:\mvn-test\src\main\webapp]
[INFO] Webapp assembled in [100 msecs]
[INFO] Building war: C:\mvn-test\target\mvn-test.war
[INFO] WEB-INF\web.xml already added, skipping
[INFO] ----------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ----------------------------------------------------------------
[INFO] Total time: 53.939 s
[INFO] Finished at: 2017-01-09T00:51:51+09:00
[INFO] Final Memory: 13M/136M
[INFO] ----------------------------------------------------------------
SUCCESSになりました! 生成されたフォルダの内容を確認します。
C:\MVN-TEST
│ pom.xml
├─src
│ └─main
│ ├─resources
│ └─webapp
│ │ index.jsp
│ └─WEB-INF
│ web.xml
└─target
│ mvn-test.war
├─classes
├─maven-archiver
│ pom.properties
└─mvn-test
│ index.jsp
├─META-INF
└─WEB-INF
│ web.xml
└─classes
うまく生成されたようです。
Copyright (C) 2017 ymlib.com