Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

351
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda