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

215
Vistas
Spring: override parent bean

Is it possible to override/replace parent abstract bean?

E.G: 1st xml:

<bean id="inheritedTestBean" abstract="true" class="org.springframework.beans.TestBean">
</bean>

<bean id="inheritsWithDifferentClass" class="org.springframework.beans.DerivedTestBean" parent="inheritedTestBean">
</bean>

2nd xml

<bean id="inheritedTestBean2" abstract="true" class="org.springframework.beans.TestBean2">
</bean>
<alias name="inheritedTestBean2" alias="inheritedTestBean" />

TestBean2 inherits TestBean.

about 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

Any given Spring context can only have one bean for any given id or name. In the case of the XML id attribute, this is enforced by the schema validation. In the case of the name attribute, this is enforced by Spring's logic.

However, if a context is constructed from two different XML descriptor files, and an id is used by both files, then one will "override" the other. The exact behaviour depends on the ordering of the files when they get loaded by the context.

So while it's possible, it's not recommended. It's error-prone and fragile, and you'll get no help from Spring if you change the ID of one but not the other.

about 4 years ago · Santiago Trujillo Denunciar

0

Even if you could do this, it would be very confusing. There is the @Primary annotation, you can take a look at that. Or you could take a look at spring profiles, so you have a default bean implementation, and then every other profile there is a different implementation for your abstract class.

about 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