2017-02-06 8 views
2

私はSpringboot 1.5を使ってサービスをテストしようとしています。私はFilterRegestionBeanのNoクラスが見つかりました。Springboot 1.5いいえClasse defサービスをテストしようとしたときにFilterRegistrationBeanが見つかりました

@RunWith(SpringRunner.class) 
@SpringBootTest 
class ApiServiceSpecTest { 

    @Autowired 
    ApiService apiService; 

    @Test 
    public void testGetApis() { 
     List<Api> apis = this.apiService.getApis("KFS") 
     given(this.apiService.getApis("KFS")).willReturn("some stuff") 
    assertThat(!apis.empty) 
} 

私のbuild.gradleは以下のようになります。私は、ドキュメントをチェックし、私は例を実装しましたが、私はそれを実行するために得ることができないような気がしてきました

compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-sleuth', version:'1.1.1.RELEASE' 
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version:'1.5.1.RELEASE' 
compile group: 'org.springframework.boot', name: 'spring-boot-starter-actuator', version:'1.5.1.RELEASE' 
compile group: 'org.springframework.boot', name: 'spring-boot-starter-jdbc', version:'1.5.1.RELEASE' 
compile group: 'org.springframework.boot', name: 'spring-boot-starter-mail', version:'1.5.1.RELEASE' 
compile(group: 'org.springframework.boot', name: 'spring-boot-starter-test', version:'1.5.1.RELEASE') 

。どんな助けでも大歓迎です。

答えて

0

FilterRegistrationBeanは、Springブート1.4.xでは廃止され、Springブート1.5では削除される可能性が高い(パッケージが変更されたのみ)。 spring-cloud-sleuthの依存関係はおそらくSpring Boot 1.4に基づいているので、古いパッケージのFilterRegistrationBeanクラスを使ってトレースフィルタをインスタンス化しようとすると、実行時の問題が発生します。

解決方法:今日のちょうど出てきた1.1.2.RELEASEに、あなたはspring-cloud-sleuth依存関係を更新してください:Releaseと関連するGithub issue

+0

はどうもありがとうございます! – Ryan

0

春のブート1.5以降では、FilterRegistrationBeanクラスを移動しました。私はから私のimport文を変更して、それを解決 -

輸入 org.springframework.boot.context.embedded.FilterRegistrationBean。

輸入org.springframework.boot.web.servlet.FilterRegistrationBeanへ。

これが機能しました。これは、スプリングブート1.5.1リリースと1.5.2リリースで動作します。

ソース - spring boot FilterReistrationBean

関連する問題