![](/img/trans.png)
[英]Class not mapping from Get API Request in Spring Boot, how to map to object>
[英]How to get an object in spring boot from REQUEST scope
如何在Spring Boot中從幾個類的REQUEST范圍獲取對象(不轉發到類)。 那些。 在每個類中,有必要為當前請求提供一個實際的對象。 如果可能的話。
@Bean(name = "wp")
@Scope(value = WebApplicationContext.SCOPE_REQUEST, proxyMode = ScopedProxyMode.TARGET_CLASS)
public WrapperRequest getWrapperRequest() {
WrapperRequest wrapperRequest = new WrapperRequest();
wrapperRequest.setJdbcTemplate(jdbcTemplate);
return wrapperRequest;
}
您可以在Spring上下文中的類中@Autowired
(例如,具有@Component
@Service
, @Repository
, @Service
@Repository
批注的類)
例:
@Autowired
private WrapperRequest wp;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.