I need to exclude these two packages based on any conditional value from an external source before running my application.
Since I need to determine these packages based on an external value before building , I cant use hardcoded annotations.
@ComponentScan( basePackages = "com.ReadDB.reader", excludeFilters = { @ComponentScan.Filter(type = FilterType.REGEX, pattern = "com\.ReadDB\.reader\.opendental\.."), @ComponentScan.Filter(type = FilterType.REGEX, pattern = "com\.ReadDB\.reader\.mysql\..") } )
this annotation on my main class is working ,
<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<context:component-scan base-package="com.ReadDB.reader">
<context:exclude-filter type="regex" expression="com\.ReadDB\.reader\.opendental\..*"/>
<context:exclude-filter type="regex" expression="com\.ReadDB\.reader\.mysql\..*"/>
</context:component-scan>
</beans>
but this xml file in my resources folder and @ImportResource("classpath:applicationContext.xml") annotation on my main class is not working.
Any idea on how to fix this.