Skip to content

Inheriting from entity types causes failure when using entity-defined Regions #112

Description

@yozaner1324

Failure:
The bean 'Person' could not be registered. A bean with that name has already been defined and overriding is disabled.

Scenario:
This occurs when a class extends a data class annotated with @Region, even if the subclass is not used.

Example:

@Region("Person")
class Person{
	@Id
	private String name;
	public Person(String name) {
		this.name = name;
	}

	public String getName() {
		return name;
	}
}

class Customer extends Person {
	public Customer(String name) {
		super(name);
	}
}

If Customer doesn't extend Person, there is no issue, but if it does, the application context will fail to load.

Work arounds:

  • Set spring.main.allow-bean-definition-overriding to true
  • Don't use entity defined regions
  • Don't inherit from data classes used to define regions.

Repo reproducing issue: https://github.com/yozaner1324/SBDG-using-sealed-classes

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions