STS4の設定手順 ================================================================================ .. only:: html .. contents:: 目次 :depth: 3 :local: | | Spring Tool Suite(以降STSと呼ぶ)とは、EclipseをベースにSpringでの開発に適した機能が組み込まれている統合開発環境である。 | 本章ではTERASOLUNA Server Framework for Java (5.x)で解説するアプリケーション開発に適した設定方法について解説する。 なお、以降の解説はJava、Maven及びアプリケーションサーバーがインストールされていることを前提としている。これらのインストール手順については各自で調査されたい。 | .. _SpringToolSuite4WhatIsSTS4: Spring Tool Suite 4とは -------------------------------------------------------------------------------- | STS4は過去のSTSを踏襲せずSpring Bootでの開発に適したツールとして作成されている。 | 従来のSpringアプリケーション開発に対しては不足している機能があるため、不足部分の補完方法についてこの章で解説していく。 | .. _SpringToolSuite4Installing: STS4の導入手順 -------------------------------------------------------------------------------- .. _SpringToolSuite4InstallingIDE: STS4の導入 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | STS本体は\ `STSの公式ページ `_\ から取得することができる。 | 過去のバージョンのSTSを使用したい場合は\ `STSのGitHub `_\ からダウンロードされたい。 なお、以下で紹介する導入手順はWindowsを前提としているため注意されたい。 ダウンロードした「spring-tool-suite-4-4.x.x.RELEASE-e4.xx.x-win32.win32.x86_64.self-extracting.jar」を以下のどちらかの手順で実行すると、ダウンロードしたファイルが配置されているフォルダにSTS4が展開される。 * ダウンロードした「spring-tool-suite-4-4.x.x.RELEASE-e4.xx.x-win32.win32.x86_64.self-extracting.jar」をダブルクリック * コマンドラインから\ ``java -jar spring-tool-suite-4-4.x.x.RELEASE-e4.xx.x-win32.win32.x86_64.self-extracting.jar``\ を実行する。 展開完了後、展開されたフォルダ内の「SpringToolSuite4.exe」を実行することでSTSを起動することができる。 | .. _SpringToolSuite4InstallingPlugin: プラグインの導入 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | STS4には従来のJakarta EE(Java EE)Webアプリケーション開発向けのWeb Tools Platform (WTP)やJSPエディタなどが搭載されていない、従来のSpring アプリケーション開発向けのXML形式のBean定義ファイルがサポートされていない等、TERASOLUNA Server Framework for Java (5.x)で解説するアプリケーション開発に必要な機能が不足している。 | プラグインの導入はEclipse Marketplace経由で行う。 | STSのメニューから、Help > EclipseMarketplaceを選択し、以下のプラグインを導入する。 * Eclipse Enterprise Java and Web Developer Tools Webアプリ開発用のプラグイン(WTP)やJSPエディタを使用するために必要なプラグイン。 .. figure:: ./images_SpringToolSuite4/SpringToolSuite4EnterpriseJavaPlugin.png :alt: Eclipse Marketplace :align: center :width: 75% * Spring Tools 3 Add-On for Spring Tools 4 | xml形式のbean定義ファイルをサポートするためのプラグイン。 | STS4に入っているプラグインと一部の機能が競合するためそのままではインストールできないため、「Update my installation to be compatible with the items being installed」にチェックを入れて互換性を持たせた状態でインストールを行う。 .. figure:: ./images_SpringToolSuite4/SpringToolSuite4Spring3Plugin.png :alt: Eclipse Marketplace :align: center :width: 75% .. note:: STS 4.17.1.RELEASEに対しSpring Tools 3 Add-On for Spring Tools 4をインストールする際に、以下の様なエラーが発生することを確認している。 .. code-block:: console Cannot complete the install because one or more required items could not be found. Software being installed: Spring IDE Integration, Flex and Web Services Extension (optional) 3.9.22.202204280911-RELEASE (org.springframework.ide.eclipse.integration.feature.feature.group 3.9.22.202204280911-RELEASE) Missing requirement: Spring IDE Configuration Graphical Editing 3.9.22.202204280911-RELEASE (org.springframework.ide.eclipse.config.graph 3.9.22.202204280911-RELEASE) requires 'osgi.bundle; org.eclipse.mylyn.commons.ui [3.7.0,4.0.0)' but it could not be found Cannot satisfy dependency: From: Spring IDE Core (required) 3.9.22.202204280911-RELEASE (org.springframework.ide.eclipse.feature.feature.group 3.9.22.202204280911-RELEASE) To: org.eclipse.equinox.p2.iu; org.springframework.ide.eclipse.config.graph [3.9.22.202204280911-RELEASE,3.9.22.202204280911-RELEASE] Cannot satisfy dependency: From: Spring IDE Integration, Flex and Web Services Extension (optional) 3.9.22.202204280911-RELEASE (org.springframework.ide.eclipse.integration.feature.feature.group 3.9.22.202204280911-RELEASE) To: org.eclipse.equinox.p2.iu; org.springframework.ide.eclipse.feature.feature.group 0.0.0 これは、Eclipse IDEからEclipse Mylyn Task UIが削除されたことが原因であるため、個別にMylynをインストールする必要がある。 * Eclipse Mylyn タスク指向UIを提供するプラグイン。 1. STSのメニューから、Help > Install New Softwareを選択し、Work withに「\ ``https://download.eclipse.org/mylyn/releases/latest``\ 」を入力する。 2. Mylyn Featuresを選択し、インストールを行う。 .. figure:: ./images_SpringToolSuite4/SpringToolSuite4mylyn.png :alt: Eclipse Marketplace :align: center :width: 70% .. _SpringToolSuite4DynamicWebModule: .. note:: ビルド時にJSPファイルで以下のエラーが発生する場合がある。 .. code-block:: console The superclass "javax.servlet.http.HttpServlet", determined from the Dynamic Web Module facet version (2.5), was not found on the Java Build Path この状態は、Dynamic Web Moduleのバージョンをあげることで解消できる。 プロジェクト名を右クリックし、「Properties」を選択 ->「Project Facets」の「Dynamic Web Module」を5.0へ変更することで解決する。 .. figure:: ./images_SpringToolSuite4/SpringToolSuite4DynamicWebModule.png :alt: Eclipse Marketplace :align: center :width: 75% .. _SpringToolSuite4ProxySettings: .. note:: プロキシ環境下でプラグインを導入する場合、プロキシ設定を行わないとEclipse MarketPlaceに接続できずプラグインを導入することができない。 プロキシ設定は以下の手順で行える。 * STSのメニューから、Window > Preferences > General > Network Connections からプロキシ設定を開き、Active ProviderをManualにしてHTTPとHTTPSにプロキシを設定する。 .. figure:: ./images_SpringToolSuite4/SpringToolSuite4Proxy.png :alt: SpringToolSuite Proxy Settings :align: center :width: 50% | .. _SpringToolSuite4AdvanceSettings: 作業用の事前設定 -------------------------------------------------------------------------------- .. _SpringToolSuite4JavascriptEditorSettings: JavaScriptのエディタ設定 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | eclipse 2020-06リリース以降、JavaScript用に使用されるエディタがJavaScript DevelopmentTools(以降JSDTと呼ぶ)で提供されていたJavaScript Editorから、Eclipse Wild Web Developerというプラグインで提供されるGeneric Text Editor(もしくは普通のText Editor)に変更されている。 | この影響でformatter.xmlを使用してのJavaScriptのフォーマットが行えないため、以下の手順でJSDTを導入する必要がある。 1. STSのメニューから、Help > Install New Softwareを選択し、Work withに「\ ``https://download.eclipse.org/releases/latest/``\ 」を入力する。 2. Web,XML,Java EE and OSGi Enterprise Development > JavaScript Development Tools を選択し、インストールを行う。 .. figure:: ./images_SpringToolSuite4/SpringToolSuite4javascript.png :alt: Eclipse Marketplace :align: center :width: 75% .. note:: JSDTのインストール後、再起動を行うことで自動的に.jsファイルをJavaScript Editorで開くようになる。自動的に切り替わらない場合は、STSのメニューから、Window > Preferences > General > Editors > File Associations を開き、\*.jsファイルに対してJavaScript Editorを関連付ける。 | .. _SpringToolSuite4Perspective: Perspective設定 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | STS4はデフォルトではSpringでの開発に適した画面レイアウトになっていない。 | STSのメニューから、Window > Perspective > Open Perspective > Other を選択し、PerspectiveをSpringに切り替えることでSpringでのアプリケーション開発に適した画面レイアウトにすることが出来る。 | .. _SpringToolSuite4JavaSettings: Java設定 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | STSの設定によっては予め用意したJDKではなくSTSに同梱されているJDKなどが使用される場合があるので、以下の手順でJDKの設定を確認する。 1. STSのメニューから、Window > Preferences > Java > Installed JREs を開き、予め用意したJDKにチェックがついていることを確認する。 2. 用意したJDKが一覧に存在しない場合は AddからStandard VMを選択し、Directoryから用意したJDKを選択し追加する。 .. figure:: ./images_SpringToolSuite4/SpringToolSuite4Java.png :alt: SpringToolSuite Java Settings :align: center :width: 50% | .. _SpringToolSuite4MavenSettings: Maven設定 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | STSはデフォルトだとSTSに同梱されたMavenを使用するため、以下の手順で予め用意したMavenを使用するよう設定する。 1. Window > Preferences > Maven > Installations からAddを選択し、Directoryから用意したMavenを選択し追加する。 .. figure:: ./images_SpringToolSuite4/SpringToolSuite4Maven.png :alt: SpringToolSuite Maven Settings :align: center :width: 50% | .. _SpringToolSuite4ServerSettings: Server設定 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | 過去のSTSではSTS本体にアプリケーションサーバが同梱されていたが、STS4からは同梱されなくなった。そのため、以下の手順でアプリケーションサーバの追加を行う。 | ここでは例としてTomcatを使用する場合の設定手順について説明する。 1. Serverビューを右クリックし、New > Serverを選択する。 2. Apache配下から使用しているTomcatのバージョンと一致するTomcatを選択しNextを押下する。 3. Browseから事前にインストールしておいたtomcatを選択し、Finishを押下する。 4. サーバにアプリケーションを設定したい場合は、追加したサーバを右クリックしてAdd and Removeを選択する。表示された画面のAvailableにある動作させたいアプリケーションを選択し、AddでConfiguredに追加してFinishを押下する。 5. アプリケーションを設定したサーバを右クリックし、Startを選択してサーバを起動する。 .. figure:: ./images_SpringToolSuite4/SpringToolSuite4Server.png :alt: SpringToolSuite Server Settings :align: center :width: 50% .. raw:: latex \newpage