当对象的默认生存期为单例时,并发在SpringBoot中如何工作

问题描述

在ASP.NET中,在IoC容器中创建的对象的默认生命周期是每个Web请求。在学习SpringBoot + Webflux时,我发现IoC容器创建的默认生命周期(Bean,存储库,服务等)是单例的。我知道我可以这样更改默认范围:

 map.on('load',function() {
   // We use D3 to fetch the JSON here so that we can parse and use it separately
   // from GL JS's use in the added source. You can use any request method (library
   // or otherwise) that you want.
   d3.json(
     'PATH TO YOUR GEOJSON FILE',function(err,data) {
       if (err) throw err;
       map.addSource('stores',{
                 'type': 'geojson','data': data
           });

       map.addLayer({
           'id': 'stores','type': 'circle','source': 'stores','paint': {
             'circle-radius': 6
           }
       });
       data.features.forEach(function(store,i){
         store.properties.id = i;
       });
       buildLocationList(data);

     });

});

但是我还没有找到一个可以使用它的例子。因此,如果IoC将所有对象都创建为单例,那么并发不会有问题。有人可以向我解释一下。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)