2017-07-27 12 views
0

私は2つのエンドポイントしか定義されていないスプリングブートアプリケーションを持っています。春のブート時に "/"への直接アクセスを削除する

@RequestMapping(value = "/getAllFeatures", method = RequestMethod.GET) 
     @Cacheable("features") 
     public ResponseEntity<?> getAllFeatures() { 
    ... 
    } 

    @RequestMapping(name = "/getFeatureStatus", method = RequestMethod.GET) 
     @Cacheable("features") 
     public ResponseEntity<?> getFeatureStatus(@RequestParam(value = "groupName", required = false) String groupName, 
       @RequestParam(value = "featureName", required = false) String featureName) { 
... 
    } 

と私はserver.contextパスするコンテキストを定義している=/ABCのI/ABC /上GET呼び出しを行うときに問題があるどのように

アプリケーションは私に有効な応答を提供します。どこで私は決して "/"私の残りのコントローラにマップされていません。リクエストを "/"にブロックする方法に関するアイデア。また、このアプリケーションはどんな種類のスプリングセキュリティも必要としません。

答えて

1

それは

@RequestMapping(path= "/getFeatureStatus"....) 

代わりの

@RequestMapping(name = "/getFeatureStatus"....) 

name属性は、ちょうどこのマッピングに名前を割り当てなければなりません。

+0

'org.springframework.beans.factory.BeanCreationException:クラスパスリソース[org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration $ EnableWebMvcConfiguration.class]で定義された 'requestMappingHandlerMapping'という名前のBeanを作成中にエラーが発生しました: ;ネストされた例外はjava.lang.IllegalStateException:あいまいなマッピングです。 'featuresController'メソッドをマップできません public org.springframework.http.ResponseEntity com.util.controller.FeaturesController.getAllFeatures() to {[]、methods = [GET]}:既に 'featuresController' beanメソッドがあります – Rohit

+0

私は上記の例外を受け取ります – Rohit

+0

両方のメソッドのコードを変更しましたか? – RSingh

0

"/"エンドポイントがリソースフォルダのindex.htmlファイルにマップされることがあります。 このファイルは存在しますか? また、@RestControllerでクラスに注釈を付ける必要があります。

関連する問題