かんがるーさんの日記

最近自分が興味をもったものを調べた時の手順等を書いています。今は Spring Boot をいじっています。

共有ライブラリを管理するために Sonatype の Nexus Repository Manager OSS を使用する ( 大目次 )

  1. その1 ( 概要 )
  2. その2 ( Windows 版の Nexus Repository Manager OSS をインストールする )
  3. その3 ( Nexus Repository Manager OSS の画面を一通り見てみる )
  4. その4 ( IntelliJ IDEA の Project Defaults を設定する )
  5. その5 ( 簡単なライブラリを作成して Nexus に登録してみる )
  6. 番外編 ( IntelliJ IDEA を 2016.1.3 → 2016.2 へバージョンアップ )
  7. その6 ( 登録した ksbysample-library-simpleutils ライブラリを Spring Boot のプロジェクトから利用してみる )
  8. その7 ( ksbysample-library-simpleutils ライブラリをアップロードし直した時の挙動と、1.0-SNAPSHOT で呼び出せるのかを確認する )
  9. 番外編 ( Java SE を 8u92 → 8u102 へ、Git for Windows を 2.9.0 → 2.9.2 へバージョンアップ )
  10. その8 ( build.gradle に 1.0-SNAPSHOT のバージョンで記述している時にライブラリを更新するとすぐに反映されるのか? )
  11. その9 ( 1.0-SNAPSHOT のバージョンのまま Nexus にアップロードできるのか? )
  12. その10 ( 1.0-RELEASE で Nexus にアップロードする )
  13. その11 ( Nexus を 3.0.0-03 → 3.0.1-01 へバージョンアップする )
  14. 番外編 ( build.gradle にコマンドを書いて実行する )
  15. 番外編 ( IntelliJ IDEA を 2016.2 → 2016.2.1 へバージョンアップ )
  16. その12 ( 他のライブラリに依存するライブラリを作成する )
  17. その13 ( 利用するライブラリが依存しているライブラリの別バージョンを build.gradle で指定したらどうなるのか? )
  18. 番外編 ( IntelliJ IDEA を 2016.2.1 → 2016.2.2 へバージョンアップ )
  19. その14 ( sources と javadoc をアップロードする )
  20. その15 ( pom ファイルに name, description を追加する )
  21. 番外編 ( Gradle のバージョンを 3.0 に上げてみようとしたら Spring Boot 1.4.0 以降が必要でした )
  22. 番外編 ( IntelliJ IDEA を 2016.2.2 → 2016.2.4 へバージョンアップ )
  23. 番外編 ( Java SE を 8u102 → 8u112 へ、Git for Windows を 2.9.2 → 2.10.2 へバージョンアップ )
  24. 番外編 ( IntelliJ IDEA を 2016.2.4 → 2016.3 へバージョンアップ )
  25. 番外編 ( IntelliJ IDEA 2016.3 の新機能を試してみる )
  26. その16 ( Nexus を 3.0.1-01 → 3.1.0-04 へバージョンアップする )
  27. その17 ( Nexus へコンポーネントを登録する専用 User を作成する )
  28. その18 ( Spring Framework に依存するライブラリを作成する )
  29. その19 ( Spring Framework に依存するライブラリを作成する2 )
  30. その20 ( Spring Framework に依存するライブラリを作成する3 )
  31. その21 ( Spring Framework に依存するライブラリを作成する4 )
  32. その22 ( Spring Framework に依存するライブラリを作成する5 )
  33. その23 ( Spring Framework に依存するライブラリを作成する6 )
  34. 番外編 ( IntelliJ IDEA を 2016.3 → 2016.3.2 へ、Git for Windows を 2.10.2 → 2.11.0 へバージョンアップ )
  35. その24 ( Nexus を 3.1.0-04 → 3.2.0-01 へバージョンアップする )
  36. その25 ( Windows 版 Nexus 3 インストール手順 )
  37. その26 ( Linux のサーバに Nexus Repository Manager OSS をインストールする )

共有ライブラリを管理するために Sonatype の Nexus Repository Manager OSS を使用する ( その26 )( Linux のサーバに Nexus Repository Manager OSS をインストールする )

概要

共有ライブラリを管理するために Sonatype の Nexus Repository Manager OSS を使用する ( その25 )( Windows 版 Nexus 3 インストール手順 ) の続きです。

参照したサイト・書籍

目次

  1. Oracle VM VirtualBox のインストール
  2. Vagrant のインストール
  3. CentOS の仮想サーバを構築する
  4. Unix 版 Nexus Repository Manager OSS をインストールする
  5. JDK をインストールする
  6. 動作確認
  7. サービスとして登録・起動する
  8. ksbysample-library-depend-spring ライブラリをアップロードしてみる
  9. 次回は。。。

手順

Oracle VM VirtualBox のインストール

  1. Download VirtualBox のページの「Windows hosts」リンクをクリックし、VirtualBox-5.1.12-112440-Win.exe をダウンロードします。

    f:id:ksby:20170103193035p:plain

  2. VirtualBox-5.1.12-112440-Win.exe を実行します。

  3. Oracle VM VirtualBox 5.1.12 Setup」ダイアログが表示されます。「Next >」ボタンをクリックします。

  4. 「Custom Setup」画面が表示されます。「Location」を C:\virtualbox\ に変更した後、「Next >」ボタンをクリックします。

    f:id:ksby:20170103194330p:plain

  5. 次の画面が表示されます。チェックの状態を以下の画像の通り変更した後、「Next >」ボタンをクリックします。

    f:id:ksby:20170103194512p:plain

    ※「Create start menu entries」だけチェックを残したのは、仮想サーバの情報を確認するために VirtualBox の管理画面を見たい場合があるためです。

  6. 「Warning: Network Interfaces」画面が表示されます。「Yes」ボタンをクリックします。

  7. 「Ready to Install」画面が表示されます。「Install」ボタンをクリックします。

    インストールの途中で以下のようなダイアログが3回表示されますので都度「インストール」ボタンをクリックします。

    f:id:ksby:20170103194918p:plain

  8. インストールが完了すると「Oracle VM VirtualBox 5.1.12 installation is complete」画面が表示されます。「Start Oracle VM VirtualBox 5.1.12 after installation」のチェックボックスを外した後、「Finish」ボタンをクリックします。

Vagrant のインストール

  1. DOWNLOAD VAGRANT のページの Windows の「Universal (32 and 64-bit)」のリンクをクリックし、vagrant_1.9.1.msi をダウンロードします。

  2. vagrant_1.9.1.msi を実行します。

  3. Vagrant Setup」ダイアログが表示されます。「Next」ボタンをクリックします。

  4. 「End-User License Agreement」画面が表示されます。「I accept the terms in the License Agreement」をチェックした後、「Next」ボタンをクリックします。

  5. Destination Folder」画面が表示されます。C:\vagrant\ に変更した後、「Next」ボタンをクリックします。

  6. 「Ready to install Vagrant」画面が表示されます。「Install」ボタンをクリックします。

  7. インストールが完了すると「Completed the Vagrant Setup Wizard」画面が表示されます。「Finish」ボタンをクリックします。

  8. PC の再起動を求めるダイアログが表示されるので、「YES」ボタンをクリックして再起動します。

CentOS の仮想サーバを構築する

  1. C:\work\vagrant フォルダを作成します。

  2. C:\work\vagrant の下に boxes フォルダを作成します。

  3. Vagrantbox.es のページの以下の画像の赤枠の box ファイルの URL をコピーします。

    f:id:ksby:20170103232741p:plain

  4. コピーした URL をブラウザのアドレスバーにペーストして box ファイル centos-7-x86_64.box をダウンロードし、C:\work\vagrant\boxes の下に保存します。

  5. vagrant box add コマンドでダウンロードした box ファイルを追加します。

    f:id:ksby:20170104112823p:plain

  6. C:\work\vagrant の下に nexus-server フォルダを作成します。

  7. vagrant init コマンドで Vagrantfile を作成します。作成された時点の Vagrantfile は リンク先のその1の内容 です。

    f:id:ksby:20170104114633p:plain

  8. Vagrantfile をエディタで開き リンク先のその2の内容 に変更します。今はメモリを 2GB に増やすだけです。

  9. vagrant up コマンドを実行して仮想サーバを起動します。

    f:id:ksby:20170104120332p:plain f:id:ksby:20170104120502p:plain

  10. 起動した仮想サーバに ssh でアクセスしたいので、ssh.exe が入っている C:\Git\usr\bin を環境変数 PATH に追加します。

  11. vagrant ssh コマンドで仮想サーバに接続できることを確認します。

    f:id:ksby:20170104121041p:plain

Unix 版 Nexus Repository Manager OSS をインストールする

  1. Download Nexus Repository OSS ( http://www.sonatype.com/download-oss-sonatype ) のページにアクセスします。

  2. ページ内の「nexus-3.2.0-01-unix.tar.gz」リンクをクリックしてダウンロードします。

    f:id:ksby:20170104131229p:plain

  3. ダウンロードした nexus-3.2.0-01-unix.tar.gz を C:\work\vagrant\nexus-server に移動します。

  4. vagrant ssh で接続して /opt の下にインストールします。

    f:id:ksby:20170104183419p:plain

JDK をインストールする

  1. nexus run を実行しようとしてみたところエラーメッセージが出ました。/opt/nexus-3.2.0-01/bin の下を見たところ Windows 版にあった jre ディレクトリが存在しませんでしたので、別途インストールします。

    f:id:ksby:20170104212858p:plain

  2. Java SE Development Kit 8 Downloads の「Java SE Development Kit 8u112」の「jdk-8u112-linux-x64.tar.gz」リンクをクリックしてダウンロードします。

  3. ダウンロードした jdk-8u112-linux-x64.tar.gz を C:\work\vagrant\nexus-server に移動します。

  4. 以下のコマンドを実行し、jdk-8u112-linux-x64.tar.gz を展開して /opt/jdk1.8.0_112 を作成した後、/opt/java というシンボリックリンクを作成します。

    f:id:ksby:20170105191147p:plain

  5. /etc/profile.d の下に java.sh を作成し、リンク先の内容 を記述します。記述後は以下のようになります。

    f:id:ksby:20170105191712p:plain

  6. Ctrl+D を押してログアウトした後、再度 vagrant ssh で接続して java -version でバージョン情報が表示されることを確認します。

    f:id:ksby:20170105192526p:plain

動作確認

※動作確認前に Windows 版 nexus のサービスは停止しています。

  1. http://localhost:8081/ でアクセスした時に仮想サーバの nexus の管理画面にアクセスできるよう Vagrantfile を リンク先のその3の内容 に変更します。

  2. vagrant haltvagrant up を実行して仮想サーバを再起動します。

    f:id:ksby:20170105195036p:plain

  3. nexus run を実行します。

    f:id:ksby:20170105195822p:plain

    (.....しばらくログが出力され続けます.....)

    f:id:ksby:20170105195931p:plain

  4. http://localhost:8081/ にアクセスして管理画面が表示されることを確認します。

    f:id:ksby:20170105202616p:plain

  5. Ctrl+C を押して nexus を停止します。

サービスとして登録・起動する

  1. /opt/nexus-3.2.0-01 → /opt/nexus のシンボリックリンクを作成します。

    f:id:ksby:20170105220855p:plain

  2. /etc/systemd/system/ の下に nexus.service を作成し、リンク先の内容 を記述します。

    f:id:ksby:20170105221506p:plain

  3. systemctl コマンドで nexus を起動します。

    f:id:ksby:20170105222140p:plain

  4. http://localhost:8081/ にアクセスして管理画面が表示されることを確認します。

    f:id:ksby:20170105222359p:plain

  5. サーバ起動後に nexus が自動起動されるか確認します。vagrant haltvagrant up を実行して仮想サーバを再起動します。

    f:id:ksby:20170105222713p:plain

  6. vagrant ssh で接続して nexus が起動していることを確認します。また http://localhost:8081/ にアクセスして管理画面が表示されることも確認します。

    f:id:ksby:20170105223018p:plain

ksbysample-library-depend-spring ライブラリをアップロードしてみる

  1. IntelliJ IDEA で ksbysample-library-depend-spring プロジェクトを開きます。

  2. uploadArchives タスクを実行して登録します。BUILD SUCCESSFUL が表示されることが確認できます。

    f:id:ksby:20170105225113p:plain

  3. nexus の管理画面を見ると ksbysample-library-depend-spring ライブラリが登録されていることが確認できます。

    f:id:ksby:20170105225334p:plain

次回は。。。

目次を作成して感想を書いて締める予定です。

ソースコード

Vagrantfile

■その1

# -*- mode: ruby -*-
# vi: set ft=ruby :

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
  # The most common configuration options are documented and commented below.
  # For a complete reference, please see the online documentation at
  # https://docs.vagrantup.com.

  # Every Vagrant development environment requires a box. You can search for
  # boxes at https://atlas.hashicorp.com/search.
  config.vm.box = "centos-7-x86_64"

  # Disable automatic box update checking. If you disable this, then
  # boxes will only be checked for updates when the user runs
  # `vagrant box outdated`. This is not recommended.
  # config.vm.box_check_update = false

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine. In the example below,
  # accessing "localhost:8080" will access port 80 on the guest machine.
  # config.vm.network "forwarded_port", guest: 80, host: 8080

  # Create a private network, which allows host-only access to the machine
  # using a specific IP.
  # config.vm.network "private_network", ip: "192.168.33.10"

  # Create a public network, which generally matched to bridged network.
  # Bridged networks make the machine appear as another physical device on
  # your network.
  # config.vm.network "public_network"

  # Share an additional folder to the guest VM. The first argument is
  # the path on the host to the actual folder. The second argument is
  # the path on the guest to mount the folder. And the optional third
  # argument is a set of non-required options.
  # config.vm.synced_folder "../data", "/vagrant_data"

  # Provider-specific configuration so you can fine-tune various
  # backing providers for Vagrant. These expose provider-specific options.
  # Example for VirtualBox:
  #
  # config.vm.provider "virtualbox" do |vb|
  #   # Display the VirtualBox GUI when booting the machine
  #   vb.gui = true
  #
  #   # Customize the amount of memory on the VM:
  #   vb.memory = "1024"
  # end
  #
  # View the documentation for the provider you are using for more
  # information on available options.

  # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies
  # such as FTP and Heroku are also available. See the documentation at
  # https://docs.vagrantup.com/v2/push/atlas.html for more information.
  # config.push.define "atlas" do |push|
  #   push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"
  # end

  # Enable provisioning with a shell script. Additional provisioners such as
  # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
  # documentation for more information about their specific syntax and use.
  # config.vm.provision "shell", inline: <<-SHELL
  #   apt-get update
  #   apt-get install -y apache2
  # SHELL
end

■その2

  config.vm.provider "virtualbox" do |vb|
  #   # Display the VirtualBox GUI when booting the machine
  #   vb.gui = true
  #
    # Customize the amount of memory on the VM:
    vb.memory = "2048"
  end

■その3

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine. In the example below,
  # accessing "localhost:8080" will access port 80 on the guest machine.
  # config.vm.network "forwarded_port", guest: 80, host: 8080
  config.vm.network "forwarded_port", guest: 8081, host: 8081
  • config.vm.network "forwarded_port", guest: 8081, host: 8081 を追加します。

java.sh

JAVA_HOME=/opt/java
PATH=$PATH:$JAVA_HOME/bin

nexus.service

[Unit]
Description=nexus service
After=network.target

[Service]
Type=forking
ExecStart=/opt/nexus/bin/nexus start
ExecStop=/opt/nexus/bin/nexus stop
User=nexus
Restart=on-abort

[Install]
WantedBy=multi-user.target

履歴

2017/01/05
初版発行。

共有ライブラリを管理するために Sonatype の Nexus Repository Manager OSS を使用する ( その25 )( Windows 版 Nexus 3 インストール手順 )

概要

共有ライブラリを管理するために Sonatype の Nexus Repository Manager OSS を使用する ( その24 )( Nexus を 3.1.0-04 → 3.2.0-01 へバージョンアップする ) の続きです。

  • 今回の手順で確認できるのは以下の内容です。
    • Windows 版 Nexus 3 ( 3.1以降 ) のインストール手順をまとめます。
    • 3.1 以降の正式バージョンがリリースされた後にクリーンインストールの手順をまとめていなかったので、今回はクリーンインストールの手順を記述します。
    • 2017/1/3 時点でダウンロード可能な最新版 nexus-3.2.0-01-win64.zip を使用します。
    • インストール先は C:\nexus です。

参照したサイト・書籍

  1. Documentation Nexus Repository Manager 3.2 - Chapter 2. Installation and Running
    https://books.sonatype.com/nexus-book/reference3/install.html

目次

  1. nexus-3.2.0-01-win64.zip をダウンロードする
  2. C:\nexus ディレクトリを作成する
  3. nexus-3.2.0-01-win64.zip を解凍し、ディレクトリ・ファイル一式を移動する
  4. nexus /run を実行する
  5. サービスを登録して起動する
  6. 動作確認
  7. メモ書き
    1. nexus 起動時の JavaVM のオプションを変更するには?
    2. nexus から Maven Central Repository へアクセスする際に Proxy サーバがある場合には?

手順

nexus-3.2.0-01-win64.zip をダウンロードする

  1. Download Nexus Repository OSS ( http://www.sonatype.com/download-oss-sonatype ) のページにアクセスします。

  2. ページ内の「nexus-3.2.0-01-win64.zip」リンクをクリックしてダウンロードします。

    f:id:ksby:20170103105534p:plain

C:\nexus ディレクトリを作成する

  1. C:\ の下に nexus ディレクトリを作成します。

nexus-3.2.0-01-win64.zip を解凍し、ディレクトリ・ファイル一式を移動する

  1. nexus-3.2.0-01-win64.zip を解凍します。解凍すると nexus-3.2.0-01, sonatype-work の2つのフォルダが作成されます。

  2. nexus-3.2.0-01, sonatype-work の2つのフォルダを C:\nexus の下に移動します。移動後の C:\nexus の下のディレクトリ構成は以下のようになります。

    f:id:ksby:20170103144513p:plain

nexus /run を実行する

  1. nexus /run を実行し、Started Sonatype Nexus OSS 3.2.0-01 が出力されることを確認します。

    f:id:ksby:20170103152740p:plain f:id:ksby:20170103152901p:plain f:id:ksby:20170103153026p:plain f:id:ksby:20170103153132p:plain f:id:ksby:20170103153245p:plain f:id:ksby:20170103153351p:plain

    nexus の初回起動時のログを見ていると、初めて見るソフトもあって面白いです。

    • Jetty が使用されている。
    • Apache Shiro というものが使用されている ( このソフトは初めて聞きました )。
    • OrientDB というものが使用されている ( このソフトも初めて聞きました )。
    • Ehcache が使用されている。
    • elasticsearch が使用されている。
    • Quartz Scheduler というものが使用されている ( このソフトも初めて聞きました )。
  2. Ctrl+C を押して、起動した nexus を停止します。

サービスを登録して起動する

  1. コマンドプロンプトを「管理者として実行...」で起動した後、nexus /install nexus を実行しサービスを登録します。

    f:id:ksby:20170103161710p:plain

    f:id:ksby:20170103161839p:plain

  2. 「サービスの開始」リンクをクリックして起動します。

    f:id:ksby:20170103162009p:plain

動作確認

  1. http://localhost:8081/ にアクセスして管理画面が表示されることを確認します。

    f:id:ksby:20170103162456p:plain

  2. admin / admin123 でログインできることを確認します。

    f:id:ksby:20170103162618p:plain

    f:id:ksby:20170103162749p:plain

メモ書き

nexus 起動時の JavaVM のオプションを変更するには?

C:\nexus\nexus-3.2.0-01\bin の下にある nexus.vmoptions を編集します。nexus /run 実行直後は以下の内容でした。

-Xms1200M
-Xmx1200M
-XX:MaxDirectMemorySize=2G
-XX:+UnlockDiagnosticVMOptions
-XX:+UnsyncloadClass
-XX:+LogVMOutput 
-XX:LogFile=../sonatype-work/nexus3/log/jvm.log
-Djava.net.preferIPv4Stack=true
-Dkaraf.home=.
-Dkaraf.base=.
-Dkaraf.etc=etc/karaf
-Djava.util.logging.config.file=etc/karaf/java.util.logging.properties
-Dkaraf.data=../sonatype-work/nexus3
-Djava.io.tmpdir=../sonatype-work/nexus3/tmp
-Dkaraf.startLocalConsole=false

nexus から Maven Central Repository へアクセスする際に Proxy サーバがある場合には?

管理画面から設定します。

f:id:ksby:20170103171759p:plain

ソースコード

履歴

2017/01/03
初版発行。

共有ライブラリを管理するために Sonatype の Nexus Repository Manager OSS を使用する ( その24 )( Nexus を 3.1.0-04 → 3.2.0-01 へバージョンアップする )

概要

共有ライブラリを管理するために Sonatype の Nexus Repository Manager OSS を使用する ( その23 )( Spring Framework に依存するライブラリを作成する6 ) の続きです。

参照したサイト・書籍

目次

  1. nexus-3.2.0-01-win64.zip をダウンロードする
  2. nexus のサービスを停止する
  3. サービスを削除する
  4. nexus-3.2.0-01-win64.zip を解凍し C:\nexus にコピーする
  5. サービスを登録して起動する
  6. 動作確認
  7. C:\nexus\nexus-3.1.0-04 を削除する

手順

nexus-3.2.0-01-win64.zip をダウンロードする

  1. Download Nexus Repository OSS ( http://www.sonatype.com/download-oss-sonatype ) のページにアクセスします。

  2. ページ内の「nexus-3.2.0-01-win64.zip」リンクをクリックしてダウンロードします。

    f:id:ksby:20170103105534p:plain

nexus のサービスを停止する

  1. 管理ツールのサービスを開いてサービス一覧から「nexus」を選択した後、「サービスの停止」リンクをクリックしてサービスを停止します。

    f:id:ksby:20170103110324p:plain

サービスを削除する

  1. コマンドプロンプトを「管理者として実行...」で起動した後、nexus.exe /uninstall nexus を実行しサービスを削除します。

    f:id:ksby:20170103112406p:plain

    f:id:ksby:20170103112612p:plain

nexus-3.2.0-01-win64.zip を解凍し C:\nexus にコピーする

  1. nexus-3.2.0-01-win64.zip を解凍します。解凍すると nexus-3.2.0-01, sonatype-work の2つのフォルダが作成されます。

  2. nexus-3.2.0-01, sonatype-work の2つのフォルダを C:\nexus の下にコピーします。

サービスを登録して起動する

  1. 「管理者として実行...」で起動しているコマンドプロンプトから nexus.exe /install nexus を実行しサービスを登録します。

    f:id:ksby:20170103113722p:plain

    f:id:ksby:20170103113910p:plain

  2. 「サービスの開始」リンクをクリックして起動します。

    f:id:ksby:20170103114724p:plain

動作確認

  1. http://localhost:8081/ にアクセスして管理画面が表示されることを確認します。

    f:id:ksby:20170103115220p:plain

    コンポーネント一覧にもこれまで登録していたものが表示されています。

    f:id:ksby:20170103115445p:plain

C:\nexus\nexus-3.1.0-04 を削除する

  1. C:\nexus\nexus-3.1.0-04 を削除します。

ソースコード

履歴

2017/01/03
初版発行。

共有ライブラリを管理するために Sonatype の Nexus Repository Manager OSS を使用する ( 番外編 )( IntelliJ IDEA を 2016.3 → 2016.3.2 へ、Git for Windows を 2.10.2 → 2.11.0 へバージョンアップ )

IntelliJ IDEA を 2016.3 → 2016.3.2 へバージョンアップする

IntelliJ IDEA の 2016.3.1 が出ていることには気付いていてバージョンアップしなければと思っていましたが、いざバージョンアップしようとしたら 2016.3.2 がリリースされていました。2016.3.2 へバージョンアップします。

※ksbysample-nexus-repomng/ksbysample-library-depend-spring プロジェクトを開いた状態でバージョンアップしています。

  1. IntelliJ IDEA のメインメニューから「Help」-「Check for Updates...」を選択します。

  2. 「Platform and Plugin Updates」ダイアログが表示されます。左下に「Update and Restart」ボタンが表示されていますので、「Update and Restart」ボタンをクリックします。

    f:id:ksby:20161229163058p:plain

  3. JRebel for IntelliJ の update も表示されたので、チェックしたまま「Update and Restart」ボタンをクリックします。

    f:id:ksby:20161229163227p:plain

  4. Patch がダウンロードされて IntelliJ IDEA が再起動した後、画面下部に「Indexing...」のメッセージが表示されますので、終了するまで待機します。

    f:id:ksby:20161229164455p:plain

  5. 処理が終了すると Gradle projects View のツリーの表示が other グループしかない初期の状態に戻っていますので、左上の「Refresh all Gradle projects」ボタンをクリックして更新します。更新が完了すると build グループ等が表示されます。

  6. clean タスク実行 → Rebuild Project 実行をした後、build タスクを実行して "BUILD SUCCESSFUL" のメッセージが表示されることを確認します。

    f:id:ksby:20161229164846p:plain

  7. Project View で src/test を選択した後、コンテキストメニューを表示して「Run 'All Tests' with Coverage」を選択し、テストが全て成功することを確認します。

    f:id:ksby:20161229165143p:plain

Git for Windows を 2.10.2 → 2.11.0 へバージョンアップする

Git for Windows も 2.11.0 がリリースされていたのでバージョンアップします。

  1. https://git-for-windows.github.io/ の「Download」ボタンをクリックして Git-2.11.0-64-bit.exe をダウンロードします。

  2. Git-2.11.0-64-bit.exe を実行します。

  3. 「Git 2.11.0 Setup」ダイアログが表示されます。[Next >]ボタンをクリックします。

  4. 「Select Components」画面が表示されます。全てのチェックが外れたままであることを確認した後、[Next >]ボタンをクリックします。

  5. 「Adjusting your PATH environment」画面が表示されます。中央の「Use Git from the Windows Command Prompt」が選択されていることを確認後、[Next >]ボタンをクリックします。

  6. 「Configuring the line ending conversions」画面が表示されます。「Checkout Windows-style, commit Unix-style line endings」が選択されていることを確認した後、[Next >]ボタンをクリックします。

  7. 「Configuring the terminal emulator to use with Git Bash」画面が表示されます。「Use Windows'default console window」が選択されていることを確認した後、[Next >]ボタンをクリックします。

  8. 「Configuring extra options」画面が表示されます。「Enable file system caching」だけがチェックされていることを確認した後、[Next >]ボタンをクリックします。

  9. 「Configuring experimental options」画面が表示されます。全てのチェックが外れたままであることを確認した後、[Install]ボタンをクリックします。

  10. インストールが完了すると「Completing the Git Setup Wizard」のメッセージが表示された画面が表示されます。中央の「View ReleaseNotes.html」のチェックを外した後、「Finish」ボタンをクリックしてインストーラーを終了します。

  11. コマンドプロンプトを起動して git のバージョンが 2.11.0 になっていることを確認します。

    f:id:ksby:20161229230039p:plain

  12. git-cmd.exe の起動も問題ないようですので、このまま 2.11.0 で作業を進めたいと思います。

    f:id:ksby:20161229230238p:plain

共有ライブラリを管理するために Sonatype の Nexus Repository Manager OSS を使用する ( その23 )( Spring Framework に依存するライブラリを作成する6 )

概要

共有ライブラリを管理するために Sonatype の Nexus Repository Manager OSS を使用する ( その22 )( Spring Framework に依存するライブラリを作成する5 ) の続きです。

  • 今回の手順で確認できるのは以下の内容です。
    • ksbysample-library-depend-spring を導入してもデフォルトでは動作せず、ksbysample.library.request-and-response-logger.enabled=true を設定した時だけ動作するように変更します。

参照したサイト・書籍

目次

  1. RequestAndResponseLoggerAutoConfiguration クラスで ksbysample.library.request-and-response-logger.enabled=true が設定されていなければ Bean を生成しないようにする
  2. Nexus に登録する
  3. ksbysample-webapp-demo プロジェクトで動作を確認する
  4. 次回は。。。

手順

RequestAndResponseLoggerAutoConfiguration クラスで ksbysample.library.request-and-response-logger.enabled=true が設定されていなければ Bean を生成しないようにする

  1. ksbysample-library-depend-spring プロジェクトを開きます。

  2. バージョンを 1.1.0-RELEASE に変更します。build.gradle を リンク先の内容 に変更します。

  3. src/main/java/ksbysample/library/dependspring/config の下の RequestAndResponseLoggerAutoConfiguration.javaリンク先の内容 に変更します。

  4. テストします。src/test/java/ksbysample/library/dependspring/config の下の RequestAndResponseLoggerAutoConfigurationTest.javaリンク先の内容 に変更します。

  5. テストを実行します。RequestAndResponseLoggerAutoConfigurationTest クラスのクラス名の左側に表示されているアイコンをクリックしてコンテキストメニューを表示後「Run 'RequestAndResponseLoggerAutoCo...'」を選択します。

    テストは全て成功し、デフォルト状態ではログは出力されず、ksbysample.library.request-and-response-logger.enabled=true を定義すればログが出力されることが確認できます。

    f:id:ksby:20161229135551p:plain

    f:id:ksby:20161229135709p:plain

Nexus に登録する

  1. clean タスク実行 → Rebuild Project 実行をした後 build タスクを実行して、エラーが出ないことを確認します。

    f:id:ksby:20161229140148p:plain

  2. Gradle projects View から uploadArchives タスクを実行します。BUILD SUCCESSFUL が表示されて正常に Nexus に登録されました。

    f:id:ksby:20161229140424p:plain

  3. Nexus の管理画面を見ると、登録されていることが確認できます。

    f:id:ksby:20161229140616p:plain

ksbysample-webapp-demo プロジェクトで動作を確認する

  1. ksbysample-library-depend-spring プロジェクトを閉じて ksbysample-webapp-demo プロジェクトを開きます。

  2. build.gradle を リンク先のその1の内容 に変更します。変更後、Gradle projects View の左上にある「Refresh all Gradle projects」ボタンをクリックして反映します。

  3. bootRun タスクを実行して Tomcat を起動した後、http://localhost:8080/sample にアクセスします。まだ ksbysample.library.request-and-response-logger.enabled=true を設定していないので、request, response のログが出力されません。

    f:id:ksby:20161229142752p:plain

    Tomcat を停止します。

  4. build.gradle を リンク先のその2の内容 に変更します。

  5. 再度 bootRun タスクを実行して Tomcat を起動した後、http://localhost:8080/sample にアクセスします。今度は request, response のログが出力されます。

    f:id:ksby:20161229144016p:plain

    Tomcat を停止します。

  6. 動作確認が完了したので、commit します。また feature/3-issue ブランチを develop, master ブランチへマージして、Issue #3 をクローズします。

次回は。。。

  • Nexus 3 の正式版 ( 3.1 以降 ) のインストールは 3.0.x からのバージョンアップとして記述していたので、Windows版Nexus のインストール方法をまとめ直します。
  • VirtualBox+Vagrant をインストールして Linux の仮想サーバを構築し、Unix 版の Nexus Repository Manager OSS をインストールして使用してみます。

ソースコード

ksbysample-library-depend-spring/build.gradle

group 'ksbysample.library'
version '1.1.0-RELEASE'
  • version の値を 1.0.0-RELEASE1.1.0-RELEASE に変更します。

RequestAndResponseLoggerAutoConfiguration.java

package ksbysample.library.dependspring.config;

import ksbysample.library.dependspring.intercepter.RequestAndResponseLogger;
import org.apache.commons.lang3.StringUtils;
import org.springframework.aop.Advisor;
import org.springframework.aop.aspectj.AspectJExpressionPointcut;
import org.springframework.aop.support.DefaultPointcutAdvisor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RequestAndResponseLoggerAutoConfiguration {

    private static final String REQUESTMAPPING_EXPRESSION = "@annotation(org.springframework.web.bind.annotation.RequestMapping)";

    @Value("${ksbysample.library.request-and-response-logger.execution:}")
    private String execution;

    @Bean
    @ConditionalOnWebApplication
    @ConditionalOnProperty(value = {"ksbysample.library.request-and-response-logger.enabled"}, havingValue = "true")
    public Advisor requestAndResponseLoggerAdvisor() {
        AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
        String expression = StringUtils.EMPTY;
        if (StringUtils.isNotBlank(this.execution)) {
            expression = this.execution + " && ";
        }
        expression += REQUESTMAPPING_EXPRESSION;
        pointcut.setExpression(expression);
        return new DefaultPointcutAdvisor(pointcut, new RequestAndResponseLogger());
    }

}
  • @ConditionalOnProperty(value = {"ksbysample.library.request-and-response-logger.enabled"}, havingValue = "true") を追加します。

RequestAndResponseLoggerAutoConfigurationTest.java

package ksbysample.library.dependspring.config;

import ksbysample.library.dependspring.Application;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.runners.Enclosed;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.OutputCapture;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;

import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

@RunWith(Enclosed.class)
public class RequestAndResponseLoggerAutoConfigurationTest {

    public static abstract class TestBase {

        public MockMvc mvc;

        @Autowired
        private WebApplicationContext context;

        @Rule
        public OutputCapture capture = new OutputCapture();

        @Before
        public void setUp() throws Exception {
            this.mvc = MockMvcBuilders.webAppContextSetup(this.context)
                    .build();
        }

    }

    @RunWith(SpringJUnit4ClassRunner.class)
    @SpringApplicationConfiguration(classes = Application.class)
    @WebAppConfiguration
    public static class デフォルトの設定でのテスト extends TestBase {

        @Test
        public void ログが出力されない() throws Exception {
            mvc.perform(get("/test"))
                    .andExpect(status().isOk());
            assertThat(capture.toString()).doesNotContain("[req][info  ] REQUEST_URI = /test");
            assertThat(capture.toString()).doesNotContain("[res][info  ] RESPONSE_STATUS = 200");
        }

    }

    @RunWith(SpringJUnit4ClassRunner.class)
    @SpringApplicationConfiguration(classes = Application.class)
    @WebAppConfiguration
    @TestPropertySource(properties = {
            "ksbysample.library.request-and-response-logger.enabled=true"
    })
    public static class enabledプロパティ設定時のテスト extends TestBase {

        @Test
        public void ログが出力される() throws Exception {
            mvc.perform(get("/test"))
                    .andExpect(status().isOk());
            assertThat(capture.toString()).contains("[req][info  ] REQUEST_URI = /test");
            assertThat(capture.toString()).contains("[res][info  ] RESPONSE_STATUS = 200");
        }

    }

    @RunWith(SpringJUnit4ClassRunner.class)
    @SpringApplicationConfiguration(classes = Application.class)
    @WebAppConfiguration
    @TestPropertySource(properties = {
            "ksbysample.library.request-and-response-logger.enabled=true"
            , "ksbysample.library.request-and-response-logger.execution=execution(* ksbysample.library.dependspring..*.*(..))"
    })
    public static class executionプロパティ設定時のテスト_出力される設定 extends TestBase {

        @Test
        public void ログが出力される() throws Exception {
            mvc.perform(get("/test"))
                    .andExpect(status().isOk());
            assertThat(capture.toString()).contains("[req][info  ] REQUEST_URI = /test");
            assertThat(capture.toString()).contains("[res][info  ] RESPONSE_STATUS = 200");
        }

    }

    @RunWith(SpringJUnit4ClassRunner.class)
    @SpringApplicationConfiguration(classes = Application.class)
    @WebAppConfiguration
    @TestPropertySource(properties = {
            "ksbysample.library.request-and-response-logger.enabled=true"
            , "ksbysample.library.request-and-response-logger.execution=execution(* ksbysample.webapp.lending.web..*.*(..))"
    })
    public static class executionプロパティ設定時のテスト_出力されない設定 extends TestBase {

        @Test
        public void ログが出力されない() throws Exception {
            mvc.perform(get("/test"))
                    .andExpect(status().isOk());
            assertThat(capture.toString()).doesNotContain("[req][info  ] REQUEST_URI = /test");
            assertThat(capture.toString()).doesNotContain("[res][info  ] RESPONSE_STATUS = 200");
        }

    }

}
  • 各クラスで同じ内容を定義をしていた部分を TestBase クラスを作成して共通化します。abstract class にしてテスト対象外になるようにします。
  • 「デフォルトの設定でのテスト」テストクラスのメソッド名を ログが出力されるログが出力されない へ変更し、メソッド内で使用している assert 用メソッドを containsdoesNotContain へ変更します。
  • ksbysample.library.request-and-response-logger.enabled=true を定義した時にログが出力されることを確認するための「enabledプロパティ設定時のテスト」テストクラスを作成します。
  • 「executionプロパティ設定時のテスト出力される設定」「executionプロパティ設定時のテスト出力されない設定」テストクラスの @TestPropertySource アノテーションksbysample.library.request-and-response-logger.enabled=true を追加します。

ksbysample-webapp-demo/build.gradle

■その1

dependencies {
    compile('org.springframework.boot:spring-boot-starter-web')
    testCompile('org.springframework.boot:spring-boot-starter-test')

    compile('ksbysample.library:ksbysample-library-simpleutils:1.0-RELEASE')
    compile('ksbysample.library:ksbysample-library-depend-nospring:1.1-RELEASE')
    compile('ksbysample.library:ksbysample-library-depend-spring:1.1.0-RELEASE')
}
  • ksbysample.library:ksbysample-library-depend-spring のバージョン番号を 1.0.0-RELEASE1.1.0-RELEASE に変更します。

■その2

dependencies {
    ..........
}

bootRun {
    jvmArgs = ['-Dksbysample.library.request-and-response-logger.enabled=true']
}

履歴

2016/12/29
初版発行。

共有ライブラリを管理するために Sonatype の Nexus Repository Manager OSS を使用する ( その22 )( Spring Framework に依存するライブラリを作成する5 )

概要

共有ライブラリを管理するために Sonatype の Nexus Repository Manager OSS を使用する ( その21 )( Spring Framework に依存するライブラリを作成する4 ) の続きです。

  • 今回の手順で確認できるのは以下の内容です。
    • 1.4 系のプロジェクトに 1.3.8 ベースの ksbysample-library-depend-spring ライブラリを導入すると Spring Boot はどのバージョンが使用されるのか確認します。

参照したサイト・書籍

目次

  1. 1.4 系のプロジェクト ksbysample-webapp-demo14 を作成する
  2. ksbysample-library-depend-spring ライブラリ導入時のログが出ることを確認する
  3. gradlew dependencies コマンドで依存関係を確認する

手順

1.4 系のプロジェクト ksbysample-webapp-demo14 を作成する

今回は IntelliJ IDEA から Spring Initializr を利用してプロジェクトを作成した後、build.gradle に Spring IO Platform の bom 等を追加します。

  1. IntelliJ IDEA の「Welcome to IntelliJ IDEA」ダイアログから「Create New Project」メニューをクリックします。

    f:id:ksby:20161228103401p:plain

  2. 「New Project」ダイアログが表示されます。画面左側の一覧から「Spring Initializr」を選択してから以下の画像の内容を入力後、「Next」ボタンをクリックします。

    f:id:ksby:20161228103742p:plain

  3. Group、Artifact 等を入力する画面が表示されます。以下の画像の内容を入力後、「Next」ボタンをクリックします。

    f:id:ksby:20161228104112p:plain

  4. Spring のプロダクトを選択する画面が表示されます。以下の画像のプロダクトをチェックした後、「Next」ボタンをクリックします。

    f:id:ksby:20161228104443p:plain f:id:ksby:20161228104719p:plain

  5. Project name と Project location を入力する画面が表示されます。以下の画像の内容になっていることを確認した後、「Finish」ボタンをクリックします。

    f:id:ksby:20161228104934p:plain

  6. 「Import Module from Gradle」ダイアログが表示されます。「Create directories for empty roots automatically」をチェックした後、「OK」ボタンをクリックします。

    f:id:ksby:20161228105525p:plain

  7. IntelliJ IDEA の 2016.3 ではプロジェクト作成直後に画面右側に「Gradle」アイコン&文字が表示されないので、一旦 IntelliJ IDEA を再起動します。

  8. build.gradle を リンク先の内容 に変更します。変更後、Gradle projects View の左上にある「Refresh all Gradle projects」ボタンをクリックして反映します。

  9. src/main/java/ksbysample/webapp/demo14 の下に TestController.java を作成し、リンク先の内容 を記述します。

ksbysample-library-depend-spring ライブラリ導入時のログが出ることを確認する

  1. Gradle projects View から bootRun タスクを実行し、Tomcat を起動します。

  2. ブラウザを起動し http://localhost:8080/test にアクセスすると、request, response のログが出力されることが確認できました。1.4 系のプロジェクトでも動作しますね。

    f:id:ksby:20161228115414p:plain

gradlew dependencies コマンドで依存関係を確認する

コマンドプロンプトを起動しカレントディレクトリを c:\project-springboot\ksbysample-nexus-repomng\ksbysample-webapp-demo14 へ移動した後、gradlew dependencies コマンドを実行してみます。

今回は org.springframework.boot:spring-boot-starter-web:1.3.8.RELEASE -> 1.4.2.RELEASE (*) と出力されており、1.4.2 が使用されていました。ライブラリ側のバージョンではなく、メインプロジェクト側のバージョンが使用されるようです。

compile - Dependencies for source set 'main'.
+--- org.springframework.boot:spring-boot-starter-web: -> 1.4.2.RELEASE
|    +--- org.springframework.boot:spring-boot-starter:1.4.2.RELEASE
|    |    +--- org.springframework.boot:spring-boot:1.4.2.RELEASE
|    |    |    +--- org.springframework:spring-core:4.3.4.RELEASE
|    |    |    \--- org.springframework:spring-context:4.3.4.RELEASE
|    |    |         +--- org.springframework:spring-aop:4.3.4.RELEASE
|    |    |         |    +--- org.springframework:spring-beans:4.3.4.RELEASE
|    |    |         |    |    \--- org.springframework:spring-core:4.3.4.RELEASE
|    |    |         |    \--- org.springframework:spring-core:4.3.4.RELEASE
|    |    |         +--- org.springframework:spring-beans:4.3.4.RELEASE (*)
|    |    |         +--- org.springframework:spring-core:4.3.4.RELEASE
|    |    |         \--- org.springframework:spring-expression:4.3.4.RELEASE
|    |    |              \--- org.springframework:spring-core:4.3.4.RELEASE
|    |    +--- org.springframework.boot:spring-boot-autoconfigure:1.4.2.RELEASE
|    |    |    \--- org.springframework.boot:spring-boot:1.4.2.RELEASE (*)
|    |    +--- org.springframework.boot:spring-boot-starter-logging:1.4.2.RELEASE
|    |    |    +--- ch.qos.logback:logback-classic:1.1.7
|    |    |    |    +--- ch.qos.logback:logback-core:1.1.7
|    |    |    |    \--- org.slf4j:slf4j-api:1.7.20 -> 1.7.21
|    |    |    +--- org.slf4j:jcl-over-slf4j:1.7.21
|    |    |    |    \--- org.slf4j:slf4j-api:1.7.21
|    |    |    +--- org.slf4j:jul-to-slf4j:1.7.21
|    |    |    |    \--- org.slf4j:slf4j-api:1.7.21
|    |    |    \--- org.slf4j:log4j-over-slf4j:1.7.21
|    |    |         \--- org.slf4j:slf4j-api:1.7.21
|    |    +--- org.springframework:spring-core:4.3.4.RELEASE
|    |    \--- org.yaml:snakeyaml:1.17
|    +--- org.springframework.boot:spring-boot-starter-tomcat:1.4.2.RELEASE
|    |    +--- org.apache.tomcat.embed:tomcat-embed-core:8.5.6
|    |    +--- org.apache.tomcat.embed:tomcat-embed-el:8.5.6
|    |    \--- org.apache.tomcat.embed:tomcat-embed-websocket:8.5.6
|    |         \--- org.apache.tomcat.embed:tomcat-embed-core:8.5.6
|    +--- org.hibernate:hibernate-validator:5.2.4.Final
|    |    +--- javax.validation:validation-api:1.1.0.Final
|    |    +--- org.jboss.logging:jboss-logging:3.2.1.Final -> 3.3.0.Final
|    |    \--- com.fasterxml:classmate:1.1.0 -> 1.3.3
|    +--- com.fasterxml.jackson.core:jackson-databind:2.8.4
|    |    +--- com.fasterxml.jackson.core:jackson-annotations:2.8.0 -> 2.8.4
|    |    \--- com.fasterxml.jackson.core:jackson-core:2.8.4
|    +--- org.springframework:spring-web:4.3.4.RELEASE
|    |    +--- org.springframework:spring-aop:4.3.4.RELEASE (*)
|    |    +--- org.springframework:spring-beans:4.3.4.RELEASE (*)
|    |    +--- org.springframework:spring-context:4.3.4.RELEASE (*)
|    |    \--- org.springframework:spring-core:4.3.4.RELEASE
|    \--- org.springframework:spring-webmvc:4.3.4.RELEASE
|         +--- org.springframework:spring-aop:4.3.4.RELEASE (*)
|         +--- org.springframework:spring-beans:4.3.4.RELEASE (*)
|         +--- org.springframework:spring-context:4.3.4.RELEASE (*)
|         +--- org.springframework:spring-core:4.3.4.RELEASE
|         +--- org.springframework:spring-expression:4.3.4.RELEASE (*)
|         \--- org.springframework:spring-web:4.3.4.RELEASE (*)
\--- ksbysample.library:ksbysample-library-depend-spring:1.0.0-RELEASE
     +--- org.springframework.boot:spring-boot-autoconfigure:1.3.8.RELEASE -> 1.4.2.RELEASE (*)
     +--- org.springframework.boot:spring-boot-starter-web:1.3.8.RELEASE -> 1.4.2.RELEASE (*)
     +--- org.aspectj:aspectjweaver:1.8.9
     +--- org.apache.commons:commons-lang3:3.5 -> 3.4
     \--- com.google.guava:guava:20.0 -> 17.0

ソースコード

ksbysample-webapp-demo14/build.gradle

buildscript {
    ext {
        springBootVersion = '1.4.2.RELEASE'
    }
    repositories {
        mavenCentral()
        maven { url "http://repo.spring.io/repo/" }
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
        classpath("io.spring.gradle:dependency-management-plugin:0.6.1.RELEASE")
    }
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

jar {
    baseName = 'ksbysample-webapp-demo14'
    version = '0.0.1-SNAPSHOT'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
    maven { url "http://localhost:8081/repository/maven-public" }
}

dependencyManagement {
    imports {
        mavenBom 'io.spring.platform:platform-bom:Athens-SR1'
    }
}

dependencies {
    compile('org.springframework.boot:spring-boot-starter-web')
    runtime('org.springframework.boot:spring-boot-devtools')
    testCompile('org.springframework.boot:spring-boot-starter-test')

    compile('ksbysample.library:ksbysample-library-depend-spring:1.0.0-RELEASE')
}
  • buildscript の以下の点を変更します。
    • Spring Boot は 1.4.3 がリリースされていますが Spring IO Platform の最新版で対応しているのは 1.4.2 なので、springBootVersion の値を 1.4.3.RELEASE1.4.2.RELEASE に変更します。
    • repositories に maven { url "http://repo.spring.io/repo/" } を追加します。
    • dependencies に classpath("io.spring.gradle:dependency-management-plugin:0.6.1.RELEASE") を追加します。
  • apply plugin: 'io.spring.dependency-management' を追加します。あと以前は apply plugin: 'spring-boot' でしたが apply plugin: 'org.springframework.boot' に変わっていますね。
  • repositories 内に書くレポジトリを mavenCentral()maven { url "http://localhost:8081/repository/maven-public" } へ変更します。
  • dependencyManagement { imports { mavenBom 'io.spring.platform:platform-bom:Athens-SR1' } } を追加します。
  • dependencies に compile('ksbysample.library:ksbysample-library-depend-spring:1.0.0-RELEASE') を追加します。

TestController.java

package ksbysample.webapp.demo14;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/test")
public class TestController {

    @RequestMapping
    @ResponseBody
    public String index() {
        return "test";
    }

}

履歴

2016/12/28
初版発行。