-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple possible bean candidates found: [DefaultInternalConstraintValidatorFactory
, DefaultConstraintValidatorFactory
]
#1266
Comments
Sorry, but the error seems to keep happening in Micronaut 4.3.2 (same steps to reproduce). |
A workaround to force the usage of the Micronaut hibernate validator package mn.hibernate.playground;
import io.micronaut.configuration.hibernate.validator.DefaultConstraintValidatorFactory;
import io.micronaut.context.BeanContext;
import io.micronaut.context.annotation.Replaces;
import jakarta.inject.Singleton;
import jakarta.validation.ConstraintValidatorFactory;
@Replaces(ConstraintValidatorFactory.class)
@Singleton
public class DefaultConstraintValidatorFactoryReplacement extends DefaultConstraintValidatorFactory {
public DefaultConstraintValidatorFactoryReplacement(BeanContext beanContext) {
super(beanContext);
}
} |
A `ConstraintValidationFactory` aws added to Micronaut Validation in [PR 288](micronaut-projects/micronaut-validation#288). This PR sets the Hibernate Validator as the primary `ConstraintValidatorFactory` in case there are many in the classpath and avoids: ``` Caused by: io.micronaut.context.exceptions.NonUniqueBeanException: Multiple possible bean candidates found: [DefaultInternalConstraintValidatorFactory, DefaultConstraintValidatorFactory] ``` see: micronaut-projects/micronaut-sql#1266
) * fix(deps): update dependency io.micronaut.validation:micronaut-validation-bom to v4.4.0 * fix: add @primary annotation for DefaultConstraintValidatorFactory A `ConstraintValidationFactory` aws added to Micronaut Validation in [PR 288](micronaut-projects/micronaut-validation#288). This PR sets the Hibernate Validator as the primary `ConstraintValidatorFactory` in case there are many in the classpath and avoids: ``` Caused by: io.micronaut.context.exceptions.NonUniqueBeanException: Multiple possible bean candidates found: [DefaultInternalConstraintValidatorFactory, DefaultConstraintValidatorFactory] ``` see: micronaut-projects/micronaut-sql#1266 --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
) A `ConstraintValidationFactory` aws added to Micronaut Validation in [PR 288](micronaut-projects/micronaut-validation#288). This PR sets the Hibernate Validator as the primary `ConstraintValidatorFactory` in case there are many in the classpath and avoids: ``` Caused by: io.micronaut.context.exceptions.NonUniqueBeanException: Multiple possible bean candidates found: [DefaultInternalConstraintValidatorFactory, DefaultConstraintValidatorFactory] ``` see: micronaut-projects/micronaut-sql#1266 --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Micronaut Framework BOM 4.3.3 will include Micronaut hibernate validator 4.2.1. We will release it by the end of the week. However, you can force it now: configurations.all {
resolutionStrategy {
force "io.micronaut.beanvalidation:micronaut-hibernate-validator:4.2.1"
}
} If in a terminal running Micronaut CLI 4.3.2, I run
then I force the micronaut-hibernate-validator to 4.2.1 with the above snippet. I add a class such as:
and modify the JPA configuration to scan for entities with:
I can run |
Expected Behavior
No exception on starting up a default Micronaut Data + Hibernate JPA app.
Actual Behaviour
The application fails to start with the following error:
Steps To Reproduce
mn create-app -b gradle -l groovy -t spock --features=h2,jdbc-tomcat,data-jpa,hibernate-jpa,hibernate-validator mn-hibernate-playground
../gradlew run
.Environment Information
Example Application
No response
Version
4.3.1
The text was updated successfully, but these errors were encountered: