我有一個 application.properties 文件,其中包含以下內容:retry.count = 3注入到 Spring MVC 控制器中@Value("${retry.count}")private int retryCount;try{ invokeRestCall()}catch(TimeOutException ex){ if(retryCount > 0) { retryCount--; //Retry call with recursion }}由于 retryCount 是在應用程序加載時注入的,而不是會話范圍內的,因此 retryCount 跨會話共享并且計數器不起作用bean 的范圍可以由 定義@Scope(value="session"),但這不適用于@Value屬性并顯示錯誤“無法為字段定義范圍”有沒有其他方法可以使字段會話作用域?
如何使 spring @Value 屬性會話作用域
慕婉清6462132
2021-06-28 17:39:21