Spring Boot2抱怨CircuitBreakerConfigurationOnMissingBean

时间:2019-08-14 07:25:29

标签: java java-8 resilience4j spring-boot-2

我已经在2.0.6版的Spring Boot上运行了Spring Boot应用程序。我添加了resilience4j以具有断路器功能,但是应用程序抱怨CircuitBreakerConfigurationOnMissingBean。

public class Testing {

  private Instrumentation.ActivityResult mActivityResult;

@Rule
public final ActivityTestRule<ComposeActivity> rule =
        new ActivityTestRule<>(ComposeActivity.class);


@Before
public void setupImageUri() {

    Resources resources = InstrumentationRegistry.getInstrumentation().getTargetContext().getResources();
    Uri imageUri = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" + resources
            .getResourcePackageName(
                    R.mipmap.ic_launcher) + '/' + resources.getResourceTypeName(
            R.mipmap.ic_launcher) + '/' + resources.getResourceEntryName(
            R.mipmap.ic_launcher));
    Intent resultData = new Intent();
    resultData.setData(imageUri);
    mActivityResult = new Instrumentation.ActivityResult(
            Activity.RESULT_OK, resultData);


}

@Test
public void testSelectImage() {

    //Setup the intent
    Intents.init();
    Matcher<Intent> expectedIntent = allOf(hasAction(Intent.ACTION_GET_CONTENT),
            hasData(android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI));
    intending(expectedIntent).respondWith(mActivityResult);

    //Click the select button
    onView(withId(R.id.attachment_button)).perform(click());
    intended(expectedIntent);
    Intents.release();

    //Check the image is displayed
    onView(withId(R.id.imageView)).check(matches(hasDrawable()));

}

public static BoundedMatcher<View, ImageView> hasDrawable() {
    return new BoundedMatcher<View, ImageView>(ImageView.class) {
        @Override
        public void describeTo(Description description) {
            description.appendText("has drawable");
        }

        @Override
        public boolean matchesSafely(ImageView imageView) {
            return imageView.getDrawable() != null;
        }
    };
}
}

尝试添加了所有必需的依赖项。 POM片段

Caused by: java.lang.IllegalStateException: Failed to introspect Class [io.github.resilience4j.circuitbreaker.autoconfigure.CircuitBreakerConfigurationOnMissingBean] from ClassLoader [jdk.internal.loader.ClassLoaders$AppClassLoader@1b9e1916

1 个答案:

答案 0 :(得分:0)

您需要使用Spring Boot版本2.1.0,因为CircuitBreakerConfigurationOnMissingBean具有仅在版本2.1.0或更高版本中可用的依赖项。