1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

maven を使ってみた時のメモ

Posted at

maven を使った時のことをメモしておきます
自分用メモです

環境

$java --version
openjdk 18.0.2 2022-07-19
OpenJDK Runtime Environment Homebrew (build 18.0.2+0)
OpenJDK 64-Bit Server VM Homebrew (build 18.0.2+0, mixed mode, sharing)

$mvn --version
Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63)
Maven home: /usr/local/Cellar/maven/3.8.6/libexec
Java version: 18.0.2, vendor: Homebrew, runtime: /usr/local/Cellar/openjdk/18.0.2/libexec/openjdk.jdk/Contents/Home
Default locale: en_JP, platform encoding: UTF-8
OS name: "mac os x", version: "12.5", arch: "x86_64", family: "mac"

やってみる

# 雛形生成
mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

# mvn package
cd my-app
mvn package

(以下略)

ERROR] Source option 5 is no longer supported. Use 7 or later.
[ERROR] Target option 5 is no longer supported. Use 7 or later.

以下の GitHub issue を参考に pom.xml に追記

Source option 5 is no longer supported. Use 6 or later. #400

  <properties>
    <maven.compiler.source>1.7</maven.compiler.source>
    <maven.compiler.target>1.7</maven.compiler.target>
  </properties>
mvn package

これで成功

Tips

settings.xml を指定して使いたい

-s オプションで指定する

# help
mvn  --help

・・・・
 -s,--settings <arg>                    Alternate path for the user
                                        settings file

# カレンとディレクトリのファイルを指定
mvn install -s settings.xml

パッケージの所在

~/.m2/repository 配下に配置されていた

通信できない場合にタイムアウトさせたい

リポジトリにアクセスできない(HTTPS 通信ができない)状況でタイムアウトすることを期待したが、2、3分ほど待ったものの、エラーが発生しなかった
明示的に settings.xml に追記をすることでタイムアウトするようになった

Mavenでリポジトリへの接続タイムアウトを設定する

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?