Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

355
Vistas
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')
    }
over 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

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>
over 4 years ago · Santiago Trujillo Denunciar

0

More information about the project setup will help with more accurate suggestions. There can be multiple way to achieve.

Assuming you have following

  1. Library has mentioned xml files
  2. We want the code not the configurations

As @Araf mentioned, we can request the team to update the library and change the configuration

  1. Restructure the code to provide Autoconfigurations files this way consumer of library can choose to load the configurations through autoload or not
  2. Define your own xml files to load so that it will not load library configurations

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.

over 4 years ago · Santiago Trujillo Denunciar

0

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'
}
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda