Search code examples
javaspringspring-mvcgradlespring-context

exclude the configuration file (.xml and package) from dependency jar in gradle spring project


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')
    }

Solution

  • 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>