spring-boot-starter-jetty 1.4.x.RELEASE 缺少 EmbeddedServletContainerFactory
spring-boot-starter-jetty 1.4.x.RELEASE missing EmbeddedServletContainerFactory
使用以下 gradle 配置时:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.4.1.RELEASE")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'spring-boot'
jar {
baseName = 'gs-starter-app'
version = '0.1.0'
}
sourceCompatibility = 1.7
targetCompatibility = 1.7
repositories {
mavenCentral()
}
configurations {
compile.exclude module: "spring-boot-starter-tomcat"
compile.exclude module: "spring-boot-starter-logging"
}
dependencies {
compile("org.springframework.boot:spring-boot-starter-web:1.4.1.RELEASE")
compile("org.springframework.boot:spring-boot-starter-actuator:1.4.1.RELEASE")
compile("org.springframework.boot:spring-boot-starter-jetty:1.4.1.RELEASE")
compile('org.springframework.boot:spring-boot-starter-log4j2:1.4.1.RELEASE')
testCompile("org.springframework.boot:spring-boot-starter-test:1.4.1.RELEASE")
testCompile("junit:junit")
}
```
The app won't start up, the exception being:
```
2016-11-07 09:36:22.900 ERROR 44150 --- [ main] o.s.b.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.1.RELEASE.jar:1.4.1.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:535) ~[spring-context-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:371) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1186) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1175) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
at com.mystuff.Application.main(Application.java:10) [main/:?]
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.1.RELEASE.jar:1.4.1.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:162) ~[spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:134) ~[spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
... 8 more
注意:我也用 1.4.0 试过这个。
但是当我回溯到 1.3.x.RELEASE 时,一切正常:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.3.8.RELEASE")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'spring-boot'
jar {
baseName = 'gs-starter-app'
version = '0.1.0'
}
sourceCompatibility = 1.7
targetCompatibility = 1.7
repositories {
mavenCentral()
}
configurations {
compile.exclude module: "spring-boot-starter-tomcat"
compile.exclude module: "spring-boot-starter-logging"
}
dependencies {
compile("org.springframework.boot:spring-boot-starter-web:1.3.8.RELEASE")
compile("org.springframework.boot:spring-boot-starter-actuator:1.3.8.RELEASE")
compile("org.springframework.boot:spring-boot-starter-jetty:1.3.8.RELEASE")
compile('org.springframework.boot:spring-boot-starter-log4j2:1.3.8.RELEASE')
testCompile("org.springframework.boot:spring-boot-starter-test:1.3.8.RELEASE")
testCompile("junit:junit")
}
我的申请 class 看起来像这样:
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class);
}
}
谷歌搜索表明最常见的原因是:
- 缺少 spring-boot-starter-web 依赖 - 这里不是这种情况
- 缺少一个 maven 插件 - 此处不合适
为什么会这样?
1.4.x 使用 Jetty 9.3,需要 java 8
我在你的构建脚本中看到你正在使用 Java 7. Spring Boot 1.4.x 使用 Jetty 9.3,它需要 java 8 (see Spring Boot's Jetty vs Java versions)
Java 7 - 回退到 Jetty 9.2
如果无法升级到 Java 8,则需要改用 Jetty 9.2 (see how-to-use-jetty-9.2-gradle)。这可以通过重新定义 属性 jetty.version
:
ext['jetty.version'] = '9.2.17.v20160517'
dependencies {
compile ('org.springframework.boot:spring-boot-starter-web') {
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-tomcat'
}
compile ('org.springframework.boot:spring-boot-starter-jetty')
}
使用以下 gradle 配置时:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.4.1.RELEASE")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'spring-boot'
jar {
baseName = 'gs-starter-app'
version = '0.1.0'
}
sourceCompatibility = 1.7
targetCompatibility = 1.7
repositories {
mavenCentral()
}
configurations {
compile.exclude module: "spring-boot-starter-tomcat"
compile.exclude module: "spring-boot-starter-logging"
}
dependencies {
compile("org.springframework.boot:spring-boot-starter-web:1.4.1.RELEASE")
compile("org.springframework.boot:spring-boot-starter-actuator:1.4.1.RELEASE")
compile("org.springframework.boot:spring-boot-starter-jetty:1.4.1.RELEASE")
compile('org.springframework.boot:spring-boot-starter-log4j2:1.4.1.RELEASE')
testCompile("org.springframework.boot:spring-boot-starter-test:1.4.1.RELEASE")
testCompile("junit:junit")
}
```
The app won't start up, the exception being:
```
2016-11-07 09:36:22.900 ERROR 44150 --- [ main] o.s.b.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.1.RELEASE.jar:1.4.1.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:535) ~[spring-context-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:371) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1186) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1175) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
at com.mystuff.Application.main(Application.java:10) [main/:?]
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.1.RELEASE.jar:1.4.1.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:162) ~[spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:134) ~[spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
... 8 more
注意:我也用 1.4.0 试过这个。 但是当我回溯到 1.3.x.RELEASE 时,一切正常:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.3.8.RELEASE")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'spring-boot'
jar {
baseName = 'gs-starter-app'
version = '0.1.0'
}
sourceCompatibility = 1.7
targetCompatibility = 1.7
repositories {
mavenCentral()
}
configurations {
compile.exclude module: "spring-boot-starter-tomcat"
compile.exclude module: "spring-boot-starter-logging"
}
dependencies {
compile("org.springframework.boot:spring-boot-starter-web:1.3.8.RELEASE")
compile("org.springframework.boot:spring-boot-starter-actuator:1.3.8.RELEASE")
compile("org.springframework.boot:spring-boot-starter-jetty:1.3.8.RELEASE")
compile('org.springframework.boot:spring-boot-starter-log4j2:1.3.8.RELEASE')
testCompile("org.springframework.boot:spring-boot-starter-test:1.3.8.RELEASE")
testCompile("junit:junit")
}
我的申请 class 看起来像这样:
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class);
}
}
谷歌搜索表明最常见的原因是:
- 缺少 spring-boot-starter-web 依赖 - 这里不是这种情况
- 缺少一个 maven 插件 - 此处不合适
为什么会这样?
1.4.x 使用 Jetty 9.3,需要 java 8
我在你的构建脚本中看到你正在使用 Java 7. Spring Boot 1.4.x 使用 Jetty 9.3,它需要 java 8 (see Spring Boot's Jetty vs Java versions)
Java 7 - 回退到 Jetty 9.2
如果无法升级到 Java 8,则需要改用 Jetty 9.2 (see how-to-use-jetty-9.2-gradle)。这可以通过重新定义 属性 jetty.version
:
ext['jetty.version'] = '9.2.17.v20160517'
dependencies {
compile ('org.springframework.boot:spring-boot-starter-web') {
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-tomcat'
}
compile ('org.springframework.boot:spring-boot-starter-jetty')
}