Anshuman Tripathy
Anshuman Tripathy

Reputation: 113

@HystrixProperty cannot be resolved to a type

I have a method marked with @HystrixCommand that has a fallback method defined. I'm trying to add a hystrix property to it so that in case of a timeout it degrades gracefully into a fallback method.

But when I add the @HystrixProperty it shows an error in the STS IDE (3.8.2 Release) saying @HystrixProperty cannot be resolved to a type.

Here is what I'm trying to do:

    @HystrixCommand(fallbackMethod="fallbackPerformOperation", 
                commandProperties={@HystrixProperty(name="execution.isolation.thread.timeoutInMilliseconds",value="5000")})
        public Future<Object> performOperation(String requestString) throws InterruptedException {  
    return new AsyncResult<Object>() {

                @Override
                public Object invoke() {.......
}}}

and this is the error being shown in the IDE:

HystrixProperty Error

I'm unable to figure out what the problem is.

Do I need to clear the STS Cache? If so how do I do it?

Thank You.

Upvotes: 0

Views: 3999

Answers (1)

Nifras Nipy
Nifras Nipy

Reputation: 101

With in the IDE it is not obvious to suggest the import HystrixProperty class, thus you need to manually import this

import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;

Then the error should be gone

Upvotes: 4

Related Questions