質問するログイン新規登録
Java

Javaは、1995年にサン・マイクロシステムズが開発したプログラミング言語です。表記法はC言語に似ていますが、既存のプログラミング言語の短所を踏まえていちから設計されており、最初からオブジェクト指向性を備えてデザインされています。セキュリティ面が強力であることや、ネットワーク環境での利用に向いていることが特徴です。Javaで作られたソフトウェアは基本的にいかなるプラットフォームでも作動します。

Spring

Spring Framework は、Javaプラットフォーム向けのオープンソースアプリケーションフレームワークです。 Java Platform上に、 Web ベースのアプリケーションを設計するための拡張機能が数多く用意されています。

Spring Boot

Spring Bootは、Javaのフレームワークの一つ。Springプロジェクトが提供する様々なフレームワークを統合した、アプリケーションを高速で開発するために設計されたフレームワークです。

Q&A

解決済

1回答

2741閲覧

STSでローカルホストに接続しようとするとローディング状態が続いてしまう

teruhisashibuya

総合スコア15

Java

Javaは、1995年にサン・マイクロシステムズが開発したプログラミング言語です。表記法はC言語に似ていますが、既存のプログラミング言語の短所を踏まえていちから設計されており、最初からオブジェクト指向性を備えてデザインされています。セキュリティ面が強力であることや、ネットワーク環境での利用に向いていることが特徴です。Javaで作られたソフトウェアは基本的にいかなるプラットフォームでも作動します。

Spring

Spring Framework は、Javaプラットフォーム向けのオープンソースアプリケーションフレームワークです。 Java Platform上に、 Web ベースのアプリケーションを設計するための拡張機能が数多く用意されています。

Spring Boot

Spring Bootは、Javaのフレームワークの一つ。Springプロジェクトが提供する様々なフレームワークを統合した、アプリケーションを高速で開発するために設計されたフレームワークです。

0グッド

0クリップ

投稿2020/08/15 08:38

編集2020/08/15 17:26

0

0

MacでSTSをダウンロードし、webアプリケーションの開発を開始しようとしたところで躓いています。ブラウザでローカルホストに接続しようとしたところ、「localhostを待機しています...」というメッセージが画面左下に表示されたまま、ローディング状態が続いてしまい困っています。(クロームのタブアイコンもグルグル回ったままになります)

イメージ説明

プロジェクトを作成するまでは以下の手順で作業を進めました。

1.「新規」→「スプリングスタータープロジェクトを作成」を選択してプロジェクトを作成
2.依存関係の追加は
WebSocket SpringBootDevTool H2Database SpringDataJPA Thymeleaf の合計5つを選択。
3.初回起動のために
・Maven設定のゴール→packageを設定
・その後プロジェクトを起動
4.controllerとview(hello.html)を作成し、localhost:8080/helloにアクセス

という流れで作業しましたが、ローカルホストへの接続が上手くいかない状況です。

作成したcontrollerとViewのソースは以下の通りです。

MainController.java

package com.example.demo.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.servlet.ModelAndView; @Controller public class MainController { @GetMapping("/hello") public ModelAndView goHello(ModelAndView mav) { mav.setViewName("hello"); return mav; } }

hello.html

<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Hello Page</title> </head> <body> <h1>Hello</h1> </body> </html>

コンソール出力

. ____ _ __ _ _ /\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ / _` | \ \ \ \ \/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v2.3.2.RELEASE) 2020-08-16 02:22:46.416 INFO 54694 --- [ restartedMain] com.example.demo.DemoApplication : Starting DemoApplication on MacBook-Pro-103.local with PID 54694 (/Users/teruhisashibuya/Documents/workspace-spring-tool-suite-4-4.7.1.RELEASE/demo/target/classes started by teruhisashibuya in /Users/teruhisashibuya/Documents/workspace-spring-tool-suite-4-4.7.1.RELEASE/demo) 2020-08-16 02:22:46.417 INFO 54694 --- [ restartedMain] com.example.demo.DemoApplication : No active profile set, falling back to default profiles: default 2020-08-16 02:22:46.452 INFO 54694 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable 2020-08-16 02:22:46.453 INFO 54694 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG' 2020-08-16 02:22:46.933 INFO 54694 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFERRED mode. 2020-08-16 02:22:46.953 INFO 54694 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 9ms. Found 0 JPA repository interfaces. 2020-08-16 02:22:47.375 INFO 54694 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http) 2020-08-16 02:22:47.384 INFO 54694 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2020-08-16 02:22:47.384 INFO 54694 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.37] 2020-08-16 02:22:47.462 INFO 54694 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2020-08-16 02:22:47.462 INFO 54694 --- [ restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1009 ms 2020-08-16 02:22:47.489 INFO 54694 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting... 2020-08-16 02:22:47.591 INFO 54694 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed. 2020-08-16 02:22:47.596 INFO 54694 --- [ restartedMain] o.s.b.a.h2.H2ConsoleAutoConfiguration : H2 console available at '/h2-console'. Database available at 'jdbc:h2:mem:b17b2c5f-c0d7-46d1-91fc-ed7d49959453' 2020-08-16 02:22:47.708 INFO 54694 --- [ restartedMain] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor' 2020-08-16 02:22:47.746 INFO 54694 --- [ task-1] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default] 2020-08-16 02:22:47.768 WARN 54694 --- [ restartedMain] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning 2020-08-16 02:22:47.784 INFO 54694 --- [ task-1] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.18.Final 2020-08-16 02:22:47.886 INFO 54694 --- [ task-1] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.0.Final} 2020-08-16 02:22:47.962 INFO 54694 --- [ task-1] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect 2020-08-16 02:22:48.042 INFO 54694 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729 2020-08-16 02:22:48.093 INFO 54694 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path '' 2020-08-16 02:22:48.095 INFO 54694 --- [ restartedMain] DeferredRepositoryInitializationListener : Triggering deferred initialization of Spring Data repositories… 2020-08-16 02:22:48.095 INFO 54694 --- [ restartedMain] DeferredRepositoryInitializationListener : Spring Data repositories initialized! 2020-08-16 02:22:48.104 INFO 54694 --- [ restartedMain] com.example.demo.DemoApplication : Started DemoApplication in 1.903 seconds (JVM running for 2.543) 2020-08-16 02:22:48.109 INFO 54694 --- [ task-1] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform] 2020-08-16 02:22:48.115 INFO 54694 --- [ task-1] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default' コード

ファイル構成
イメージ説明

念の為グーグルクロームとサファリの両環境で動作を確認しましたが、両方において同じ現象が起きています。
VisualStudioCodeでもSpringBootパッケージを利用して同じ状況を作りましたが、同様の状況です。
原因をご存知の方がいらしゃいましたら、ご指導頂けますと幸いです。

よろしくお願い致します。

〜各種バージョン情報〜
Mac Version
macOS Mojave
バージョン 10.14.6

Spring Version
Spring Tool Suite 4
Version: 4.7.1.RELEASE
Build Id: 202007271558

JDK バージョン
AMAZON-Corretto-11.0.3.7.1

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

A-pZ

2020/08/15 16:49

SpringBoot起動後のログには何かエラーは出ていないでしょうか?
teruhisashibuya

2020/08/15 17:27 編集

起動後のコンソール出力状況を質問内容欄に追加しました。 特にエラーなどは出ていなくて、問題はなさそうに見えます…。
guest

回答1

0

ベストアンサー

導入するspring-boot-starterパッケージが違います。

WebSocket(spring-boot-starter-websocket)ではなく、web(spring-boot-starter-web)です。

投稿2020/08/16 05:43

A-pZ

総合スコア12011

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

teruhisashibuya

2020/08/16 23:41

ご指摘いただきありがとうございました。 修正したところ解決致しました。 初歩的なミスでした。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.30%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問