【发布时间】:2014-10-09 04:42:06
【问题描述】:
我正在尝试将使用 Spring Boot 构建的 war 文件部署到独立的 Jetty webapps 文件夹并启动 Jetty。在 Spring 上下文初始化期间,我看到了异常:
Caused by:
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:135)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:476)
下面是我的 gradle 依赖列表:
dependencies {
compile(
"org.springframework.boot:spring-boot-starter-actuator:1.1.4.RELEASE",
"org.springframework.security:spring-security-web:3.2.3.RELEASE",
"org.springframework.security:spring-security-config:3.2.3.RELEASE",
'javax.validation:validation-api:1.0.0.GA',
'org.hibernate:hibernate-validator:4.0.0.GA',
"org.codehaus.groovy:groovy-all:2.1.1",
'com.google.code.gson:gson:2.2.1',
"javax.servlet:javax.servlet-api:3.1.0",
"com.sun.jersey:jersey-server:1.16",
"com.sun.jersey:jersey-client:1.16",
"com.sun.jersey:jersey-core:1.16",
"com.fasterxml.jackson.jaxrs:jackson-jaxrs-providers:2.3.2",
"com.sun.jersey:jersey-servlet:1.16",
"com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:2.3.2",
"com.sun.jersey.contribs:jersey-spring:1.16",
"org.springframework:spring-beans:4.0.6.RELEASE",
'com.wordnik:swagger-jersey-jaxrs_2.10:1.3.5',
'com.fasterxml.jackson.core:jackson-core:2.3.0',
"org.springframework:spring-web:4.0.6.RELEASE",
"org.springframework:spring-core:4.0.6.RELEASE",
"org.springframework:spring-tx:4.0.6.RELEASE",
"org.springframework:spring-expression:4.0.6.RELEASE",
"org.springframework:spring-webmvc:4.0.6.RELEASE",
"org.springframework:spring-context:4.0.6.RELEASE",
"org.jasypt:jasypt-spring3:1.9.1",
"com.sun.jersey.contribs:jersey-multipart:1.16",
"org.aspectj:aspectjweaver:1.7.4",
"org.springframework:spring-aspects:4.0.6.RELEASE",
"org.springframework:spring-aop:4.0.6.RELEASE",
'javax.validation:validation-api:1.0.0.GA',
'org.hibernate:hibernate-validator:4.0.0.GA'
)
compile ("org.springframework.boot:spring-boot-starter-web:1.1.4.RELEASE") {
exclude module:'spring-boot-starter-tomcat'
}
我正在使用 Spring Boot 文档中建议的 ApplicationInitializer 类。我错过了什么?如何克服这个异常?我有 Jetty 9.x 服务器。
class ApplicationInitializer extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
Properties props = getPropertiesFromArgs()
return new SpringApplicationBuilder([Application, "classpath:/META-INF/com/foo/testapp/bootstrap.xml"] as Object[])
.properties(props)
}
【问题讨论】:
标签: jetty spring-boot