2017-10-13 9 views
0

私はJARファイルとして私の春のブートアプリケーションを実行すると、すべての私のコントローラは正常に動作します(しかし、私はまだ "ハンドルメソッドが見つかりませんでした..."ログです。うまくレンダリングされた私は、WARモードでこれを実行すると、それは「のために...ハンドラメソッドが見つかりませんでした」のログに同じエラーで私に404を与えている。ここ春のブート404とまだ動作します

は私のアプリケーションクラスです。

@SpringBootApplication 
public class RAApplication extends SpringBootServletInitializer { 

    @Override 
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { 
    //set register error pagefilter false 
    //setRegisterErrorPageFilter(false); 
    return application.sources(RAApplication.class); 
    } 

    public static void main(String[] args) throws Exception { 
    SpringApplication.run(RAApplication.class, args); 
    } 
} 

私の主なアプリケーションクラスはcom.xyz.abcの下にあり、com.xyz.abc.controllersと他のすべてのコンポーネントはcom.xyz.abcの子パッケージに入っています。

/マッピングおよび/豆がうまく動作及び/マッピングは次のようなものを示します:

"{[/],methods=[GET]}":{"bean":"requestMappingHandlerMapping","method":"public java.lang.String com.xyz.abc.controllers.HomeController.renderIndexPage(org.springframework.ui.Model)"} 

ちなみに、私は[/]の場合には、それは便利ですが、1つのマッピングだけがあるにチェックを。

何が間違っている可能性がありますか?すべての通常の検索はコントローラが見つからないことを示していますが、マッピングはすべて正しくマッピングされていることを示していますが、warモードでは404を返し、jarモードではエラーが発生します。

ありがとうございます!

UPDATE:私はapplication.propertiesに

servlet.contextPath=/ 

を設定し、他のアクチュエータのエンドポイントがあまりに例えば正しく設定されている残りました

15:21:09.253 [localhost-startStop-1] INFO org.springframework.boot.web.servlet.FilterRegistrationBean - Mapping filter: 'metricsFilter' to: [/*] 
15:21:09.254 [localhost-startStop-1] INFO org.springframework.boot.web.servlet.FilterRegistrationBean - Mapping filter: 'characterEncodingFilter' to: [/*] 
15:21:09.254 [localhost-startStop-1] INFO org.springframework.boot.web.servlet.FilterRegistrationBean - Mapping filter: 'hiddenHttpMethodFilter' to: [/*] 
15:21:09.254 [localhost-startStop-1] INFO org.springframework.boot.web.servlet.FilterRegistrationBean - Mapping filter: 'httpPutFormContentFilter' to: [/*] 
15:21:09.254 [localhost-startStop-1] INFO org.springframework.boot.web.servlet.FilterRegistrationBean - Mapping filter: 'requestContextFilter' to: [/*] 
15:21:09.255 [localhost-startStop-1] INFO org.springframework.boot.web.servlet.FilterRegistrationBean - Mapping filter: 'webRequestLoggingFilter' to: [/*] 
15:21:09.255 [localhost-startStop-1] INFO org.springframework.boot.web.servlet.FilterRegistrationBean - Filter errorPageFilter was not registered (disabled) 
15:21:09.255 [localhost-startStop-1] INFO org.springframework.boot.web.servlet.FilterRegistrationBean - Mapping filter: 'applicationContextIdFilter' to: [/*] 
15:21:09.255 [localhost-startStop-1] INFO org.springframework.boot.web.servlet.ServletRegistrationBean - Mapping servlet: 'dispatcherServlet' to [/] 
15:21:09.289 [localhost-startStop-1] DEBUG org.springframework.boot.web.filter.OrderedRequestContextFilter - Initializing filter 'requestContextFilter' 
15:21:09.291 [localhost-startStop-1] DEBUG org.springframework.boot.web.filter.OrderedRequestContextFilter - Filter 'requestContextFilter' configured successfully 
15:21:09.291 [localhost-startStop-1] DEBUG org.springframework.boot.web.filter.ApplicationContextHeaderFilter - Initializing filter 'applicationContextIdFilter' 
15:21:09.291 [localhost-startStop-1] DEBUG org.springframework.boot.web.filter.ApplicationContextHeaderFilter - Filter 'applicationContextIdFilter' configured successfully 
+0

はあなたのRabbitAssistApplicationとコントローラは同じパッケージですか? –

+0

コントローラは、Applicationクラスがある子パッケージに含まれています。例えばcom.xyz.abc - applicationとcom.xyz.abc.controllers - controllers – magiclko

+0

以下のようなログが表示されていますか?swsmmaRequestMappingHandlerMapping:すべてのエンドポイントのパブリックに "{[/]}"をマップしました –

答えて

0

WARをTomcatのようなWebコンテナにデプロイする場合、コンテキストパスがあります。

たとえば、JARモードのlocalhost:8080 /は、Webコンテナのlocalhost:8080/myapp /になります。

+0

私はservlet.contextPath = /をapplication.propertiesに設定しました。言及を忘れて、質問を更新しました。ごめんなさい! – magiclko

+0

しかし、WARをどのように実行しますか? –

関連する問題