In my spring project we are using web dependency contains a configuration applicationContext.xml and security-config.xml. I have to change on both of them in my application how can I achieve this.
I'm expecting like this
compile (librariesdependencyname) {
exclude ('applicationContext.xml')
exclude ('common-security-config.xml')
}
If your team handling the jar. Just ask them to creating new version and without this configuration and resource files
OR
You can modify the context loader loaction and patter like below
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:applicationContext.xml,classpath*:/**/*-config.xml</param-value>
</context-param>
More information about the project setup will help with more accurate suggestions. There can be multiple way to achieve.
Assuming you have following
As @Araf mentioned, we can request the team to update the library and change the configuration
One way to achieve AutoConfiguration mechanism mentioned at https://docs.spring.io/spring-boot/docs/current/reference/html/features.html#features.developing-auto-configuration or as it is your own project you can try multi module project https://www.baeldung.com/spring-boot-multiple-modules
Choosing which package to load or exclude, we can use @ComponentScan https://www.baeldung.com/spring-component-scanning.
XML version of annotations should be available, I personally prefer the annotations as it will use code as configurations.
You can add a custom task in gradle and instead of adding your jar compile "dependency. Define it as "something" dependency. Access it object using configurations."something" . Refer example below
librariesdependency "<<package-librariesdependencyname>>"
jar.dependsOn 'customJar'
task customJar (type: Jar) {
archiveName = 'your-output.jar'
from zipTree(configurations.librariesdependency.singleFile)
exclude 'applicationContext.xml'
}