Skip to content
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

Remove sentinel useless annotation #3103

Merged
merged 1 commit into from
Jan 29, 2023

Conversation

ruansheng8
Copy link
Collaborator

@ruansheng8 ruansheng8 commented Jan 16, 2023

Describe what this PR does / why we need it

When my application does not used Hibernate Validator dependency , it will fail to start :

2023-01-16 16:27:54.443  WARN 4976 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.alibaba.cloud.sentinel.custom.SentinelAutoConfiguration': Unsatisfied dependency expressed through field 'properties'; nested exception is org.springframework.boot.context.properties.ConfigurationPropertiesBindException: Error creating bean with name 'spring.cloud.sentinel-com.alibaba.cloud.sentinel.SentinelProperties': Could not bind properties to 'SentinelProperties' : prefix=spring.cloud.sentinel, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is javax.validation.NoProviderFoundException: Unable to create a Configuration, because no Bean Validation provider could be found. Add a provider like Hibernate Validator (RI) to your classpath.
2023-01-16 16:27:54.448  INFO 4976 --- [           main] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2023-01-16 16:27:54.452 ERROR 4976 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

The Bean Validation API is on the classpath but no implementation could be found

Action:

Add an implementation, such as Hibernate Validator, to the classpath

See SentinelProperties.java

@ConfigurationProperties(prefix = SentinelConstants.PROPERTY_PREFIX)
@Validated
public class SentinelProperties {

and when I remove @Validated , it works

btw , We can use hibernate-validator dependency to solve it :

        <dependency>
            <groupId>org.hibernate.validator</groupId>
            <artifactId>hibernate-validator</artifactId>
        </dependency>

but i don't see any field validation annotation in this class , so i remove it.

Describe how to verify it

Verify it using the following dependencies

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
        </dependency>
        
        
        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-circuitbreaker-sentinel</artifactId>
        </dependency>
    
        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
        </dependency>
            

@ruansheng8 ruansheng8 added the area/sentinel spring cloud alibaba sentinel label Jan 16, 2023
Copy link
Collaborator

@steverao steverao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @ruansheng8 BTW, please sync to other main branchs.

@steverao steverao merged commit 588958c into alibaba:2022.x Jan 29, 2023
@steverao steverao added the waiting for sync waiting for sync to other main branchs label Jan 29, 2023
ruansheng8 added a commit to ruansheng8/spring-cloud-alibaba that referenced this pull request Jan 30, 2023
ruansheng8 added a commit to ruansheng8/spring-cloud-alibaba that referenced this pull request Jan 30, 2023
steverao pushed a commit that referenced this pull request Jan 30, 2023
steverao pushed a commit that referenced this pull request Jan 30, 2023
@steverao steverao removed the waiting for sync waiting for sync to other main branchs label Jan 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/sentinel spring cloud alibaba sentinel
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants