質問をすることでしか得られない、回答やアドバイスがある。

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

新規登録して質問してみよう
ただいま回答率
85.48%
Java

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

Eclipse

Eclipseは、IBM社で開発された統合開発環境のひとつです。2001年11月にオープンソース化されました。 たくさんのプラグインがあり自由に機能を追加をすることができるため、開発ツールにおける共通プラットフォームとして位置づけられています。 Eclipse自体は、Javaで実装されています。

Spring Boot

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

Q&A

3回答

24117閲覧

spring bootのサンプルプログラムを起動した際、サーバーが起動しない。

ArAu

総合スコア6

Java

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

Eclipse

Eclipseは、IBM社で開発された統合開発環境のひとつです。2001年11月にオープンソース化されました。 たくさんのプラグインがあり自由に機能を追加をすることができるため、開発ツールにおける共通プラットフォームとして位置づけられています。 Eclipse自体は、Javaで実装されています。

Spring Boot

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

0グッド

1クリップ

投稿2018/02/11 03:49

前提・実現したいこと

eclipseでspring bootの導入をしたい。

発生している問題・エラーメッセージ

spring bootで作成したサンプルプログラムを起動した際、サーバーが起動しない。
http://localhost:8080/webというURLにアクセスしたが、ローカルサーバーが立ってないため接続できない。
eclipse側のコンソールにエラーメッセージは表示されていない。

コンソールメッセージ . ____ _ __ _ _ /\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ / _` | \ \ \ \ \/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v1.5.10.RELEASE) 2018-02-11 12:20:26.926 INFO 8272 --- [ main] jp.co.sample.Sample2Application : Starting Sample2Application on YOLa14 with PID 8272 (C:\WorkSpace\sample2\target\classes started by YO in C:\WorkSpace\sample2) 2018-02-11 12:20:26.931 INFO 8272 --- [ main] jp.co.sample.Sample2Application : No active profile set, falling back to default profiles: default 2018-02-11 12:20:27.032 INFO 8272 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@429bd883: startup date [Sun Feb 11 12:20:27 JST 2018]; root of context hierarchy 2018-02-11 12:20:28.815 INFO 8272 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup 2018-02-11 12:20:28.843 INFO 8272 --- [ main] jp.co.sample.Sample2Application : Started Sample2Application in 2.475 seconds (JVM running for 9.185) hello() 2018-02-11 12:20:28.843 INFO 8272 --- [ Thread-2] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@429bd883: startup date [Sun Feb 11 12:20:27 JST 2018]; root of context hierarchy 2018-02-11 12:20:28.854 INFO 8272 --- [ Thread-2] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown

該当のソースコード

java

1package jp.co.sample; 2 3import org.springframework.boot.SpringApplication; 4import org.springframework.boot.autoconfigure.SpringBootApplication; 5import org.springframework.context.ConfigurableApplicationContext; 6 7@SpringBootApplication 8public class Sample2Application { 9 10 11 ConfigurableApplicationContext cac = SpringApplication.run(Sample2Application.class, args); 12 Sample2Application app = cac.getBean(Sample2Application.class); 13 app.hello(); 14 } 15 16 17 public void hello() { 18 System.out.println("hello()"); 19 } 20} 21

java

1package jp.co.sample; 2 3import org.springframework.web.bind.annotation.RequestMapping; 4import org.springframework.web.bind.annotation.RestController; 5 6@RestController 7public class WebController { 8 9 @RequestMapping("/web") 10 public String hello() { 11 return "hello()"; 12 } 13 14} 15

pom

xml

1<?xml version="1.0" encoding="UTF-8"?> 2<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 3 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4 <modelVersion>4.0.0</modelVersion> 5 6 <groupId>jp.co.ric.microservices</groupId> 7 <artifactId>weatherboot</artifactId> 8 <version>0.0.1-SNAPSHOT</version> 9 <packaging>jar</packaging> 10 11 <name>sample2</name> 12 <description>Demo project for Spring Boot</description> 13 14 <parent> 15 <groupId>org.springframework.boot</groupId> 16 <artifactId>spring-boot-starter-parent</artifactId> 17 <version>1.5.10.RELEASE</version> 18 <relativePath/> <!-- lookup parent from repository --> 19 </parent> 20 21 <properties> 22 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 23 <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> 24 <java.version>1.8</java.version> 25 </properties> 26 27 <dependencies> 28 <dependency> 29 <groupId>org.springframework.boot</groupId> 30 <artifactId>spring-boot-starter-web</artifactId> 31 </dependency> 32 33 <dependency> 34 <groupId>org.springframework.boot</groupId> 35 <artifactId>spring-boot-starter-test</artifactId> 36 <scope>test</scope> 37 </dependency> 38 </dependencies> 39 40 <build> 41 <plugins> 42 <plugin> 43 <groupId>org.springframework.boot</groupId> 44 <artifactId>spring-boot-maven-plugin</artifactId> 45 </plugin> 46 </plugins> 47 </build> 48 49 50</project>

試したこと

[spring boot 入門]という検索キーワードで、環境構築方法を調べたが、問題解決方法がみつからなかった。
[spring boot サーバー 起動しない]というキーワード検索でも、同様の症状はみつからなかった。

補足情報(FW/ツールのバージョンなど)

pleiades 4.6.2 64bit java fullversion
Springプラグイン3.8.3

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

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

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

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

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

guest

回答3

0

少なくとも、以下ではTomcatは起動しても画面は表示されずエラーとなるでしょう。

java

1 @RequestMapping("/web") 2 public String hello() { 3 return "hello()"; 4 }

正しくは return "hello"; でしょうか。

投稿2018/02/20 09:36

A-pZ

総合スコア12011

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

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

退会済みユーザー

退会済みユーザー

2018/02/20 09:38

RestController
guest

0

起動は成功して完了してると思いますよ
ポートを変更しているから 8080 でアクセスできないんじゃないんでしょうか?

投稿2018/02/11 04:44

退会済みユーザー

退会済みユーザー

総合スコア0

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

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

ArAu

2018/02/11 05:00 編集

いえ、サーバーは起動できてないはずです。 コンソールにサーバーが起動したというメッセージがでてないし、 起動してコンソール出力が終わった後に、eclipseのプログラム停止ボタンが無効状態に変化しています。 後、今回のサンプルではポート変更は行っていません、spring mvcで作った別のサンプルプログラムを起動した際はポート8080でアクセスできています。
退会済みユーザー

退会済みユーザー

2018/02/11 05:07 編集

まずサーバーは起動しています。 理由: app.hello(); の結果がログに出力されてます。 ※ サーバーの起動に失敗するとこのログは出ません。 起動ログに関しては logging.level ~ により制御が可能です。 起動ポートに関しては server.port により制御が可能です。 スプリングブートは アプリAが8080でアクセスできたからといって アプリBが8080でアクセスが可能とは限りません。
ArAu

2018/02/11 05:34

すいません、プログラム起動後にサーバーがアクセス受付状態にならず、プログラムが終了しているので、勘違いしました 改めて、server.port=8080に設定後、起動してhttp://localhost:8080/webに接続しましたが失敗しました。 log.level=debugに変更したので、debugログを貼り付けます。
ArAu

2018/02/11 05:41

debugログが900行になったので、このサイトにははりつけられませんでした
退会済みユーザー

退会済みユーザー

2018/02/11 05:49

とりあえずそのログで Tomcat started on port(s): 8080 (http) の表示は確認できましたか?
ArAu

2018/02/11 05:52

確認できないです Tomcatでログの検索かけたところ,システムプロパティでのtomcat関連のパスしかひっかからなかったです。
退会済みユーザー

退会済みユーザー

2018/02/11 06:05

だとするとプロジェクトの作成が失敗してるのかもしれない エクリプスに何かしらのエラー情報が出てませんか?
ArAu

2018/02/11 06:24

現在でていません。 あとEclipseを4.7.3のものをダウンロードして、新規でサンプルプロジェクトを作成しましたが、これもまた同様の症状です。 プログラム自体は起動するものの、ログをみてもtomcatは動いていません。
退会済みユーザー

退会済みユーザー

2018/02/11 06:43

あとは spring-boot-starter-web-1.5.10.RELEASE.jar がクラスパスにとおってないか、LOC header error が発生しているぐらいかな・・
ArAu

2018/02/11 08:33

debugログ探索すると、以下のようなのがのってましたが、これは関係ありますか? Exclusions: ----------- None Unconditional classes: ---------------------- org.springframework.boot.autoconfigure.context.ConfigurationPropertiesAutoConfiguration org.springframework.boot.autoconfigure.web.WebClientAutoConfiguration org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration org.springframework.boot.autoconfigure.info.ProjectInfoAutoConfiguration
ArAu

2018/02/11 08:39

========================= AUTO-CONFIGURATION REPORT ========================= Positive matches: ----------------- GenericCacheConfiguration matched: - Cache org.springframework.boot.autoconfigure.cache.GenericCacheConfiguration automatic cache type (CacheCondition) HttpMessageConvertersAutoConfiguration matched: - @ConditionalOnClass found required class 'org.springframework.http.converter.HttpMessageConverter'; @ConditionalOnMissingClass did not find unwanted class (OnClassCondition) HttpMessageConvertersAutoConfiguration#messageConverters matched: - @ConditionalOnMissingBean (types: org.springframework.boot.autoconfigure.web.HttpMessageConverters; SearchStrategy: all) did not find any beans (OnBeanCondition) HttpMessageConvertersAutoConfiguration.StringHttpMessageConverterConfiguration matched: - @ConditionalOnClass found required class 'org.springframework.http.converter.StringHttpMessageConverter'; @ConditionalOnMissingClass did not find unwanted class (OnClassCondition) HttpMessageConvertersAutoConfiguration.StringHttpMessageConverterConfiguration#stringHttpMessageConverter matched: - @ConditionalOnMissingBean (types: org.springframework.http.converter.StringHttpMessageConverter; SearchStrategy: all) did not find any beans (OnBeanCondition) JacksonAutoConfiguration matched: - @ConditionalOnClass found required class 'com.fasterxml.jackson.databind.ObjectMapper'; @ConditionalOnMissingClass did not find unwanted class (OnClassCondition) JacksonAutoConfiguration.Jackson2ObjectMapperBuilderCustomizerConfiguration matched: - @ConditionalOnClass found required classes 'com.fasterxml.jackson.databind.ObjectMapper', 'org.springframework.http.converter.json.Jackson2ObjectMapperBuilder'; @ConditionalOnMissingClass did not find unwanted class (OnClassCondition) JacksonAutoConfiguration.JacksonObjectMapperBuilderConfiguration matched: - @ConditionalOnClass found required classes 'com.fasterxml.jackson.databind.ObjectMapper', 'org.springframework.http.converter.json.Jackson2ObjectMapperBuilder'; @ConditionalOnMissingClass did not find unwanted class (OnClassCondition) JacksonAutoConfiguration.JacksonObjectMapperBuilderConfiguration#jacksonObjectMapperBuilder matched: - @ConditionalOnMissingBean (types: org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; SearchStrategy: all) did not find any beans (OnBeanCondition) JacksonAutoConfiguration.JacksonObjectMapperConfiguration matched: - @ConditionalOnClass found required classes 'com.fasterxml.jackson.databind.ObjectMapper', 'org.springframework.http.converter.json.Jackson2ObjectMapperBuilder'; @ConditionalOnMissingClass did not find unwanted class (OnClassCondition) JacksonAutoConfiguration.JacksonObjectMapperConfiguration#jacksonObjectMapper matched: - @ConditionalOnMissingBean (types: com.fasterxml.jackson.databind.ObjectMapper; SearchStrategy: all) did not find any beans (OnBeanCondition) JacksonHttpMessageConvertersConfiguration.MappingJackson2HttpMessageConverterConfiguration matched: - @ConditionalOnClass found required class 'com.fasterxml.jackson.databind.ObjectMapper'; @ConditionalOnMissingClass did not find unwanted class (OnClassCondition) - @ConditionalOnProperty (spring.http.converters.preferred-json-mapper=jackson) matched (OnPropertyCondition) - @ConditionalOnBean (types: com.fasterxml.jackson.databind.ObjectMapper; SearchStrategy: all) found bean 'jacksonObjectMapper' (OnBeanCondition) JacksonHttpMessageConvertersConfiguration.MappingJackson2HttpMessageConverterConfiguration#mappingJackson2HttpMessageConverter matched: - @ConditionalOnMissingBean (types: org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; SearchStrategy: all) did not find any beans (OnBeanCondition) JmxAutoConfiguration matched: - @ConditionalOnClass found required class 'org.springframework.jmx.export.MBeanExporter'; @ConditionalOnMissingClass did not find unwanted class (OnClassCondition) - @ConditionalOnProperty (spring.jmx.enabled=true) matched (OnPropertyCondition) JmxAutoConfiguration#mbeanExporter matched: - @ConditionalOnMissingBean (types: org.springframework.jmx.export.MBeanExporter; SearchStrategy: current) did not find any beans (OnBeanCondition) JmxAutoConfiguration#mbeanServer matched: - @ConditionalOnMissingBean (types: javax.management.MBeanServer; SearchStrategy: all) did not find any beans (OnBeanCondition) JmxAutoConfiguration#objectNamingStrategy matched: - @ConditionalOnMissingBean (types: org.springframework.jmx.export.naming.ObjectNamingStrategy; SearchStrategy: current) did not find any beans (OnBeanCondition) NoOpCacheConfiguration matched: - Cache org.springframework.boot.autoconfigure.cache.NoOpCacheConfiguration automatic cache type (CacheCondition) PropertyPlaceholderAutoConfiguration#propertySourcesPlaceholderConfigurer matched: - @ConditionalOnMissingBean (types: org.springframework.context.support.PropertySourcesPlaceholderConfigurer; SearchStrategy: current) did not find any beans (OnBeanCondition) RedisCacheConfiguration matched: - Cache org.springframework.boot.autoconfigure.cache.RedisCacheConfiguration automatic cache type (CacheCondition) SimpleCacheConfiguration matched: - Cache org.springframework.boot.autoconfigure.cache.SimpleCacheConfiguration automatic cache type (CacheCondition) SpringApplicationAdminJmxAutoConfiguration matched: - @ConditionalOnProperty (spring.application.admin.enabled=true) matched (OnPropertyCondition) SpringApplicationAdminJmxAutoConfiguration#springApplicationAdminRegistrar matched: - @ConditionalOnMissingBean (types: org.springframework.boot.admin.SpringApplicationAdminMXBeanRegistrar; SearchStrategy: all) did not find any beans (OnBeanCondition) ValidationAutoConfiguration matched: - @ConditionalOnClass found required class 'javax.validation.executable.ExecutableValidator'; @ConditionalOnMissingClass did not find unwanted class (OnClassCondition) - @ConditionalOnResource found location classpath:META-INF/services/javax.validation.spi.ValidationProvider (OnResourceCondition) ValidationAutoConfiguration#defaultValidator matched: - @ConditionalOnMissingBean (types: javax.validation.Validator; SearchStrategy: all) did not find any beans (OnBeanCondition) ValidationAutoConfiguration#methodValidationPostProcessor matched: - @ConditionalOnMissingBean (types: org.springframework.validation.beanvalidation.MethodValidationPostProcessor; SearchStrategy: all) did not find any beans (OnBeanCondition) WebClientAutoConfiguration.RestTemplateConfiguration matched: - @ConditionalOnClass found required class 'org.springframework.web.client.RestTemplate'; @ConditionalOnMissingClass did not find unwanted class (OnClassCondition) WebClientAutoConfiguration.RestTemplateConfiguration#restTemplateBuilder matched: - @ConditionalOnMissingBean (types: org.springframework.boot.web.client.RestTemplateBuilder; SearchStrategy: all) did not find any beans (OnBeanCondition)
ArAu

2018/02/11 08:41

NeagativeMatchのほうも以下のようなものが多数でています。 ActiveMQAutoConfiguration: Did not match: - @ConditionalOnClass did not find required classes 'javax.jms.ConnectionFactory', 'org.apache.activemq.ActiveMQConnectionFactory' (OnClassCondition)
ArAu

2018/02/11 11:17 編集

コマンドプロンプトで直接該当プロジェクトに対し、下記コマンドを実行したところhttp://localhost:8080/webにアクセスできました。 mvnw.cmd spring-boot:run -Dmaven.repo.local=localrepo ただし、eclipse側から再度実行した際は、動きませんでした。
abigail

2018/06/16 23:30

TOMCATが明らかに起動できてないでしょう。 自分で意図的に出力しない特殊な設定でもしない限り 起動したら下記みたいな感じでINFOレベルで出るはず。 2018-06-17 06:08:54.999 INFO 3680 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http) また、別ポートでも開いてないのは簡単に確認できますよ。 コマンドプロンプトを管理者権限で起動して、netstat -abの結果を当該プログラム起動前と後で見比べてみればいい。リスニングポートを開いてるプロセスは変わってないはず。これで当該プログラムが別のポートでも開いてないのは明らか。
guest

0

多分mavenのリポジトリがおかしい。
eclipseとかSTSとか何も起動してない状態で
ユーザーディレクトリ(場所が分からなければコマンドプロンプトでecho %userprofile%とか打ってください)配下の.m2ディレクトリをコピペしてどこかにバックアップをとってから、
.m2の配下にあるrepositoryディレクトリの中を全部削除してみてください。

投稿2018/06/16 23:44

abigail

総合スコア8

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

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

tgmm

2019/06/02 18:14

私もVSCodeでしたが同じように意味不明なエラーに苦しんであなたの言う通りにしましたら治りました。.m3\repository\の中身を全部消して見るのはおすすめです。初心者なので何がなんだか分かりませんけど。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問