1、@スコープ注釈
@Scopeデフォルトシングルトン、すなわちスコープ=「シングルトン」。(グローバルのみ一例)
(新しいインスタンスが存在します、すべての買収ビーン)の@Scope(「プロトタイプ」)の場合
輸入com.ccservice.flight.international.crawler.entity.CrawlerTask。 輸入com.ccservice.flight.international.crawler.entity.HttpRequestInfo; 輸入com.google.gson.JsonObject。 @Component( "AkWxpFetcher" ) @Scope( "プロトタイプ" )//多例 パブリック クラス AkWxpFetcherが延びBaseFetcherを{ }
2は、ActiveProfiles @(「テスト」 )
@ActiveProfiles
プロジェクトは、その後、道の下などに依存するテストスターターである場合は、コメント春ブーツのテストスターターは、提供されます-
<依存性> <のgroupId> org.springframework.boot </のgroupId> <たartifactId>ばねブートスタータ試験</たartifactId> <スコープ>テスト</スコープ> </依存>
テストクラスで引用
輸入java.text.DateFormatの。 輸入java.text.ParseException。 輸入java.text.SimpleDateFormatの。 輸入はjava.util.ArrayList; インポートのjava.util.Calendar; 輸入java.util.Date; 輸入はjava.util.List; 輸入org.junit.Before; 輸入org.junit.Test; 輸入org.junit.runner.RunWith; 輸入org.springframework.beans.factory.annotation.Autowired; 輸入org.springframework.beans.factory.annotation.Qualifier; 輸入org.springframework.boot.test.context.SpringBootTest; インポートorg.springframework.test.context.ActiveProfiles; 輸入org.springframework.test.context.junit4.SpringRunner。 輸入com.ccservice.flight.international.crawler.entity.CrawlerTask。 輸入com.google.gson.Gson。 輸入lombok.extern.slf4j.Slf4j。 / ** * @author WanFeng * @version 2019年7月23日下午3時16分31秒 * / @ActiveProfiles( "試験" ) @RunWith(SpringRunner。クラス) @SpringBootTest(クラス = {AkWxpParser。クラス、Gson。クラス}) SLF4J @ パブリック クラス{AkWxpParserTest @Autowired @Qualifier( "AkWxpParser" ) プライベートIParserパーサー; //インターフェイスです }