簡體   English   中英

在Jboss EAP上的springBoot應用程序,servlet上下文沒有lodaed

[英]springBoot application on Jboss EAP, servlet context not lodaed

我有一個非常簡單的Spring啟動應用程序,我想部署到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上運行這個應用程序時,使用帶有spring boot的嵌入式Tomcat。 只需點擊一下,一切都像魅力一樣。 我可以訪問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.

我究竟做錯了什么?

Spring Boot Reference Guide中找到了這個,在application.properties文件中添加以下行

server.servlet-path=/*

在jBoss EAP 6.2中對此進行了測試並且運行良好。

答案在這里: Spring Java Config vs Jboss 7

顯然“/”不適用於Jboss EAP 6.3,但“/ *”有效。 他們似乎已經用wildfly 8修了它

你在標簽中提到了JBoss 6。 根據我的經驗,Spring Boot Autoconfigure和JBoss 6(特別是)是不行的。 如果打開了Hot Deploy或者某些其他條件,JBoss VFS會對war文件中的所有jar執行一些積極的掃描。 一旦它開始掃描autoconfigure模塊中的類,它將因類似於ClassNotFoundException的錯誤而中止。 如果使用自動配置,一種解決方案可能是將彈簧模塊放在Container的lib中。 但這會使部署變得笨拙。 我沒有在JBoss 7和Wildfly 8上看到這種行為。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM