Jboss EAP上的springBoot应用程序,未放置servlet上下文 [英] springBoot application on Jboss EAP, servlet context not lodaed
问题描述
我有一个非常简单的spring boot应用程序,我想将其部署到Jboss EAP.这是我的简单应用程序类:
@SpringBootApplication
public class MayurApplication extends SpringBootServletInitializer{
public static void main(String[] args) {
SpringApplication.run(MayurApplication.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(applicationClass);
}
private static Class<MayurApplication> applicationClass = MayurApplication.class;
}
@RestController
class GreetingController {
@RequestMapping("/hello/{name}")
String hello(@PathVariable String name) {
return "Hello, " + name + "!";
}
}
,我的pom.xml也很基础.当我在Tomcat上运行此应用程序时,使用嵌入式Tomcat随Spring Boot一起提供.只需单击一下,所有内容都可以像魅力一样工作.我可以访问http://localhost:8080/demo/hello/World
,它也可以工作.
现在我试图使其成为Jboss EAP兼容战争,我通过从spring-boot-starter-web中排除来禁用了Tomcat,并将其转换为war项目. (如文章 http://spring.io/blog所建议/2014/03/07/deploying-spring-boot-applications ).
我还添加了:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>,
在抱怨.
现在所有这些都可以很好地编译并发动战争.当我将此战争复制到jboss部署时,可以看到它已成功部署在控制台上.
但是其余的api http://localhost:8080/demo/hello/World
只是无法正常工作,并不断在浏览器上引发错误:
JBWEB000068: message /demo/hello/World
JBWEB000069: description JBWEB000124: The requested resource is not available.
我在做什么错了?
@SpringBootApplication
public class MayurApplication extends SpringBootServletInitializer{
public static void main(String[] args) {
SpringApplication.run(MayurApplication.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(applicationClass);
}
private static Class<MayurApplication> applicationClass = MayurApplication.class;
}
@RestController
class GreetingController {
@RequestMapping("/hello/{name}")
String hello(@PathVariable String name) {
return "Hello, " + name + "!";
}
}
and my pom.xml is also very basic. When I run this application on Tomcat, using the embedded Tomcat what ships with spring boot. Everything works like charm in just one click. I can access http://localhost:8080/demo/hello/World
and it works too.
Now I tried to make it Jboss EAP compatible war, I disabled the Tomcat by excluding from spring-boot-starter-web, and convert it into a war project. (as suggested by article http://spring.io/blog/2014/03/07/deploying-spring-boot-applications).
I also added:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>,
as it was complaining.
Now after all this, it compiles fine and creates a war too. When I copied this war to jboss deployment, I can see it successfully deployed on console.
But the rest api http://localhost:8080/demo/hello/World
just does not work and constantly throws error on browser:
JBWEB000068: message /demo/hello/World
JBWEB000069: description JBWEB000124: The requested resource is not available.
What am I doing wrong?
Answer is here : Spring Java Config vs Jboss 7
Apparently "/" does not work on Jboss EAP 6.3 , but "/*" works. and they seems to have fixed it with wildfly 8
这篇关于Jboss EAP上的springBoot应用程序,未放置servlet上下文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!