Excluding Configuration class from SpringBootTest
You can declare a SenderConfig property in the test class, annotated as @MockBean
(and do nothing with it if you don't need it in the test) and that will effectively override the real one in the test's ApplicationContext and stop the real one from being instantiated by the BeanFactory.
https://docs.spring.io/spring-boot/docs/current/api/org/springframework/boot/test/mock/mockito/MockBean.html
How to exclude a @Configuration class when using @WebMvcTest with spring-boot?
Your use of @ComponentScan
has disabled the filters that are used by @WebMvcTest
to limit the types of components that are found by scanning.
You should remove @ComponentScan
from your main application class and use the basePackages
attribute on @SpringBootApplication
instead.
You should also move @EnableJms
and @EnableAspectJAutoProxy
to a separate @Configuration
class so that they are not enabled when using @WebMvcTest
. Alternatively, you may be able to remove them entirely as they are covered by Spring Boot’s auto-configuration.
Related Topics
How to Upload a File and Json Data in Postman
How Many Times Will This Loop Execute
Enter Array Without Knowing Its Size
Better Way to Detect If a String Contains Multiple Words
Gradle: How to Exclude a Particular Package from a Jar
Spring Boot/Spring Kafka Ssl Configuration by Environment Variables Impossible
How to Open Excel File Using JavaScript Code Without Using Activex Control
How to Remove Line Breaks from a File in Java
Launch New Activity from Fragment in Android Studio
Selenium Webdriver: Modifying Navigator.Webdriver Flag to Prevent Selenium Detection
Multipartexception: Current Request Is Not a Multipart Request
Java Fast Food Menu (Using Methods)
How to Process a Multipart Request Consisting of a File and a Json Object in Spring Restful Service
How to Return a HTML Page from a Restful Controller in Spring Boot
String.Replaceall Single Backslashes With Double Backslashes
Java.Lang.Noclassdeffounderror: Org/Json/Simple/Parser/Parseexception With Eclipse and Spring