I have a problem with spring boot. It's keeps data in a class that is annotated in:
@RestController, @Service, @Component.
I can't keep any data because it will be shared with others like a session.
Example:
@RestController
public class controller {
int x = 65;
@RequestMapping(value = "/set/{number}", method = RequestMethod.GET)
public int view(@PathVariable("number") int number) {
x = number;
return x;
}
@RequestMapping(value = "/get", method = RequestMethod.GET)
public int view2() {
return x;
}
}
First call: localhost:80802/get Result: 65.
Second call: localhost:8080/set/5 Result: 5
Third Call: localhost:8080/get Result:5
Third call Result Supposed to be: 65
This situation is also happens in the other annotations that i mentioned.
Why its use @RestController class as a kind of singleton? I cant store anything in a class that is annotated?
thanks.