In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "how to ignore a test when starting in SpringBoot". In daily operation, I believe that many people have doubts about how to ignore a test when starting in SpringBoot. The editor consulted all kinds of data and sorted out a simple and useful method of operation. I hope it will be helpful for you to answer the doubt of "how to ignore a test when starting in SpringBoot"! Next, please follow the editor to study!
SpringBoot starts ignoring a detection
When building a springboot framework, startup will check whether some connections are normal, such as redis,rabbitmq and other components. If the relevant services are not started, or if you do not use this component, you do not want to detect this.
You can fill the startup file with management.health.redis.enabled: false # # Startup does not detect redismanagement.health.rabbit.enabled: false # # Startup does not check rabbit startup to eliminate some bean injection problems
Recently, when working on a project, you need to introduce other jar. Then you need to scan some of the bean in these jar. So use the annotation: @ ComponentScan
This annotation can directly specify the package name. It will scan all the class under the package and then determine whether to parse:
ComponentScan (basePackages = {"your.pkg", "other.pkg"}) public class Application {}
The redissonConfig bean is defined in other jar. Then my own project defines the bean of redissonConfig. Causes the project to start with an error. So use the following way to exclude RedissonConfig.class from jar.
@ ComponentScan (basePackages = {"com.xx.xx.*"}, excludeFilters = @ ComponentScan.Filter (type = FilterType.ASSIGNABLE_TYPE, classes = {RedissonConfig.class}))
@ ComponentScan comment. Bean scanned or parsed can only be defined internally by Spring, such as @ Component, @ Service, @ Controller, or @ Repository. If there are some custom annotations, such as @ Consumer, the class modified by this annotation will not be scanned. At this point, we have to customize the scanner to complete this operation.
Used in the configuration file: the bottom layer of the component-scan tag uses the class ClassPathBeanDefinitionScanner to complete the scanning. The @ ComponentScan annotation is used in conjunction with the @ Configuration annotation, and the underlying ComponentScanAnnotationParser parser is used for parsing.
At this point, the study of "how to ignore a test when starting in SpringBoot" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.