2016-09-03 11 views
4

私はgradleとspringブートで遊んで始め、以下に示すような簡単なチュートリアルを選んだ。私のセットアップも以下にリストされています。grale 3とjava 7のスプリングブートはサーバーの起動時に失敗する

このチュートリアルではJava 1.8が必要であると述べていますが、gradleとbootの両方をJava 1.7でも使用できることを読んでいます。

この単純なチュートリアルがJava 1.7で動作しない理由は何ですか?どうやら...

私はgradlewを次のように作成します:gradle wrapper --gradle-version 3.0そして私のgradleビルドコマンドをususalとして実行します:./gradlew build && java -jar build/libs/gs-spring-boot-0.1.0.jar私のプロジェクトディレクトリにあります。

セットアップ:

build.gradle(:私は指定ターゲット/ sourceCompatibility = 1.7):

buildscript { 
    repositories { 
     mavenCentral() 
    } 
    dependencies { 
     classpath("org.springframework.boot:spring-boot-gradle-plugin:1.4.0.RELEASE") 
    } 
} 

apply plugin: 'java' 
apply plugin: 'eclipse' 
apply plugin: 'idea' 
apply plugin: 'spring-boot' 

jar { 
    baseName = 'gs-spring-boot' 
    version = '0.1.0' 
} 

repositories { 
    mavenCentral() 
} 

sourceCompatibility = 1.7 
targetCompatibility = 1.7 

dependencies { 
    // tag::jetty[] 
    compile("org.springframework.boot:spring-boot-starter-web") { 
     exclude module: "spring-boot-starter-tomcat" 
    } 
    compile("org.springframework.boot:spring-boot-starter-jetty") 
    // end::jetty[] 
    // tag::actuator[] 
    compile("org.springframework.boot:spring-boot-starter-actuator") 
    // end::actuator[] 
    testCompile("junit:junit") 
} 

出力エラーがで起こること

注サーバーの起動、つまりここに: org.springframework.context.ApplicationContextException: Unable to start embedded container

[email protected]:/vagrant/BootTutorial$ ./gradlew build && java -jar build/libs/gs-spring-boot-0.1.0.jar 
:compileJava UP-TO-DATE 
:processResources UP-TO-DATE 
:classes UP-TO-DATE 
:findMainClass 
:jar 
:bootRepackage 
:assemble 
:compileTestJava UP-TO-DATE 
:processTestResources UP-TO-DATE 
:testClasses UP-TO-DATE 
:test UP-TO-DATE 
:check UP-TO-DATE 
:build 

BUILD SUCCESSFUL 

Total time: 4.835 secs 

    . ____   _   __ _ _ 
/\\/___'_ __ _ _(_)_ __ __ _ \ \ \ \ 
(()\___ | '_ | '_| | '_ \/ _` | \ \ \ \ 
\\/ ___)| |_)| | | | | || (_| | )))) 
    ' |____| .__|_| |_|_| |_\__, |//// 
=========|_|==============|___/=/_/_/_/ 
:: Spring Boot ::  (v1.4.0.RELEASE) 

2016-09-03 18:57:49.456 INFO 2043 --- [   main] hello.Application      : Starting Application on precise32 with PID 2043 (/vagrant/BootTutorial/build/libs/gs-spring-boot-0.1.0.jar started by vagrant in /vagrant/BootTutorial) 
2016-09-03 18:57:49.518 INFO 2043 --- [   main] hello.Application      : No active profile set, falling back to default profiles: default 
2016-09-03 18:57:50.136 INFO 2043 --- [   main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot[email protected]65b0e5: startup date [Sat Sep 03 18:57:50 AEST 2016]; root of context hierarchy 
2016-09-03 18:57:58.795 WARN 2043 --- [   main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean. 
2016-09-03 18:57:59.019 ERROR 2043 --- [   main] o.s.boot.SpringApplication    : Application startup failed 

org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean. 
     at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:137) ~[spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEASE] 
     at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:535) ~[spring-context-4.3.2.RELEASE.jar!/:4.3.2.RELEASE] 
     at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEASE] 
     at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) [spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEASE] 
     at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:369) [spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEASE] 
     at org.springframework.boot.SpringApplication.run(SpringApplication.java:313) [spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEASE] 
     at org.springframework.boot.SpringApplication.run(SpringApplication.java:1185) [spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEASE] 
     at org.springframework.boot.SpringApplication.run(SpringApplication.java:1174) [spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEASE] 
     at hello.Application.main(Application.java:13) [classes!/:na] 
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_80] 
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_80] 
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_80] 
     at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_80] 
     at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [gs-spring-boot-0.1.0.jar:na] 
     at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [gs-spring-boot-0.1.0.jar:na] 
     at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [gs-spring-boot-0.1.0.jar:na] 
     at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:58) [gs-spring-boot-0.1.0.jar:na] 
Caused by: org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean. 
     at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.getEmbeddedServletContainerFactory(EmbeddedWebApplicationContext.java:189) ~[spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEASE] 
     at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:162) ~[spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEASE] 
     at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:134) ~[spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEASE] 
     ... 16 common frames omitted 

[email protected]:/vagrant/BootTutorial$ 
+0

既存の回答が無効になるように質問を編集しないでください。代わりに、新しい質問を作成します。 – Matt

答えて

3

Springブート1.4では、デフォルトのJettyバージョンは9.3で、JDK8が必要です。

JDK7を使用する場合は、you can use Jetty 9.2 as explained in the reference documentationです。

+0

ありがとう。私はjetty 9.2の再設定を行い、上記のbuild.gradleファイルを更新しました。今私は新しい起動エラー(元の記事を参照してください) – AHL

+0

を参照してください以下の問題を参照してください - 愚かな私は風刺漫画を実行していたし、ブートを設定する前にそれをシャットダウンしませんでした。今働く。しかし、 - 船長に私を向けるために多くのおかげで9。2つの投稿、それは最初の問題だった – AHL

+1

StackOverflowはあなた自身のためだけに作られていません。これは、同じ問題に取り組んでいる他の開発者を助けるためのものです。元の質問を編集したり変更したりすることは、特に解決されたときには、他の人にとって確かに混乱しています。今、人々は何を考えるべきですか?それは桟橋のバージョンか使用中の港ですか?どの答えが*私の問題*を解決していますか?専用の整形式の質問を作成することがゲームの一部です。 –

0

私はあなたのApplication.javaクラスがどのように見えるか分かりません。私はあなたのようなものがないと思っています。

@Configuration 
@ComponentScan 
@EnableAutoConfiguration 
public class Application { 
    public static void main(String[] args) { 
    SpringApplication.run(YourClassToRun.class, args); 
    } 
} 
+0

オリジナルの投稿にApplication.javaファイルを追加しました。私は '@ SpringBootApplication'アノテーションのみを使用します。私は他人が必要ですか、あなたは何を指していますか?ありがとう。 – AHL

1

実際にスタックを見ましたか?それは明らかに "使用中のポート8080"と言います。 2つの可能性があります。いずれかの種類のサーバーまたはサービスがポート8080をリッスンしているか、または最後の実行時にバックグラウンドにハングするスレッドがあります。

+0

ありがとう - 確かに私はまだ風刺漫画を実行していた;ええ、私はまだログを正しく読み/解釈するのに慣れています。今私はビルドコマンドを実行すると、サーバーを起動し、私はブラウザでアプリにアクセスすることができます - 歓声! – AHL

関連する問題