上一节 1.4. Dependencies

目录

下一节 1.6. Customizing the Nature of a Bean

文章目录

      • 1.5. Bean Scopes
          • Table 3. Bean scopes
        • 1.5.1. The Singleton Scope
        • 1.5.2. The Prototype Scope
        • 1.5.3. Singleton Beans with Prototype-bean Dependencies
        • 1.5.4. Request, Session, Application, and WebSocket Scopes
          • Initial Web Configuration
          • Request scope
          • Session Scope
          • Application Scope
          • Scoped Beans as Dependencies
          • Choosing the Type of Proxy to Create
        • 1.5.5. Custom Scopes
          • Creating a Custom Scope
          • Using a Custom Scope

1.5. Bean Scopes

1.5. Bean有效范围

When you create a bean definition, you create a recipe for creating actual instances of the class defined by that bean definition. The idea that a bean definition is a recipe is important, because it means that, as with a class, you can create many object instances from a single recipe.

当您创建bean definition时,您创建了一个实现方法,用于创建由该bean definition定义
的类的实际实例。
bean definition是实现方法的思想很重要,因为这意味着,与类一样,您可以从单个实现
方法创建许多对象实例。

You can control not only the various dependencies and configuration values that are to be plugged into an object that is created from a particular bean definition but also control the scope of the objects created from a particular bean definition. This approach is powerful and flexible, because you can choose the scope of the objects you create through configuration instead of having to bake in the scope of an object at the Java class level. Beans can be defined to be deployed in one of a number of scopes. The Spring Framework supports six scopes, four of which are available only if you use a web-aware ApplicationContext. You can also create a custom scope.

您不仅可以控制要插入到从特定bean定义创建的对象中的各种依赖项和配置值,
还可以控制从特定bean定义创建的对象的范围。
这种方法功能强大且灵活,因为您可以选择通过配置创建的对象的范围,
而不必在Java类级别硬编码对象的范围。
可以将bean定义为部署在多种作用域中的一种。
Spring框架支持6种作用域,其中4种作用域只支持web的ApplicationContext。
您还可以创建自定义范围。

The following table describes the supported scopes:

下表描述了支持的范围:
Table 3. Bean scopes
Scope Description
singleton (Default) Scopes a single bean definition to a single object instance for each Spring IoC container.
prototype Scopes a single bean definition to any number of object instances.
request Scopes a single bean definition to the lifecycle of a single HTTP request. That is, each HTTP request has its own instance of a bean created off the back of a single bean definition. Only valid in the context of a web-aware Spring ApplicationContext.
session Scopes a single bean definition to the lifecycle of an HTTP Session. Only valid in the context of a web-aware Spring ApplicationContext.
application Scopes a single bean definition to the lifecycle of a ServletContext. Only valid in the context of a web-aware Spring ApplicationContext.
websocket Scopes a single bean definition to the lifecycle of a WebSocket. Only valid in the context of a web-aware Spring ApplicationContext.
范围 描述
singleton (默认)将每个Spring IoC容器的单个bean definition 定位到单个对象实例.
prototype 将单个bean定义作用于任意数量的对象实例。
request 将单个bean definition 定位到单个HTTP请求的生命周期。也就是说,每个HTTP请求都有它自己的bean实例,该实例是在单个bean definition 创建的。仅在支持web的Spring ApplicationContext上下文中有效.
session 将单个bean definition作用于HTTP会话的生命周期。仅在支持web的Spring ApplicationContext上下文中有效.
application 将单个bean定义作用于ServletContext的生命周期。仅在支持web的Spring ApplicationContext上下文中有效.
websocket 将单个bean定义作用于WebSocket的生命周期。仅在支持web的Spring ApplicationContext上下文中有效。

As of Spring 3.0, a thread scope is available but is not registered by default. For more information, see the documentation for SimpleThreadScope. For instructions on how to register this or any other custom scope, see Using a Custom Scope.

Spring 3.0开始,线程范围可用,但是默认情况下没有注册。有关更多信息,请参见SimpleThreadScope的文档。有关如何注册此范围或任何其他自定义范围的说明,
请参见使用自定义范围。

1.5.1. The Singleton Scope

1.5.1. Singleton 类型的作用域

Only one shared instance of a singleton bean is managed, and all requests for beans with an ID or IDs that match that bean definition result in that one specific bean instance being returned by the Spring container.

只管理一个singleton bean的共享实例,并且所有对具有一个或多个ID的bean的请求
都与该bean定义相匹配,从而导致Spring容器返回一个特定的bean实例。

To put it another way, when you define a bean definition and it is scoped as a singleton, the Spring IoC container creates exactly one instance of the object defined by that bean definition. This single instance is stored in a cache of such singleton beans, and all subsequent requests and references for that named bean return the cached object. The following image shows how the singleton scope works:

换句话说,当您定义一个bean definition 并且它的作用域是 singleton 时,
Spring IoC容器会创建该bean definition 定义的对象的一个实例。
这个单一实例存储在这样的 singleton bean 缓存中,对这个已命名bean的
所有后续请求和引用都会返回缓存的对象。
下图显示了 singleton 的工作方式:

在这里插入图片描述

Spring’s concept of a singleton bean differs from the singleton pattern as defined in the Gang of Four (GoF) patterns book. The GoF singleton hard-codes the scope of an object such that one and only one instance of a particular class is created per ClassLoader. The scope of the Spring singleton is best described as being per-container and per-bean. This means that, if you define one bean for a particular class in a single Spring container, the Spring container creates one and only one instance of the class defined by that bean definition. The singleton scope is the default scope in Spring. To define a bean as a singleton in XML, you can define a bean as shown in the following example:

Spring的 singleton bean概念不同于“四人帮模式”一书中定义的单例模式。
GoF单例对对象的作用域进行硬编码,这样每个类加载器都会创建一个且只有一个
特定类的实例。
Spring singleton 的作用域最好描述为每个容器和每个bean。
这意味着,如果您在单个Spring容器中为特定类定义一个bean,则Spring容器将
创建该bean definition定义的类的一个且仅一个实例。
singleton 作用域是Spring中的默认作用域。要在XML中定义一个singleton 的bean,
你可以像下面的例子那样定义一个bean:
<bean id="accountService" class="com.something.DefaultAccountService"/> 
<!-- the following is equivalent, though redundant (singleton scope is the default) --> 
<bean id="accountService" class="com.something.DefaultAccountService" scope="singleton"/>

1.5.2. The Prototype Scope

1.5.2. Prototype 类型的作用域

The non-singleton prototype scope of bean deployment results in the creation of a new bean instance every time a request for that specific bean is made. That is, the bean is injected into another bean or you request it through a getBean() method call on the container. As a rule, you should use the prototype scope for all stateful beans and the singleton scope for stateless beans.
The following diagram illustrates the Spring prototype scope:

部署非 singleton 类型的 Prototype类型bean 导致每次对特定bean发出请求时都
创建一个新的bean实例。
也就是说,在将bean注入到另一个bean中,或者通过容器上的getBean()方法调用
请求它的时候。
作为一个规则,您应该对所有有状态的bean使用 Prototype 作用域,对无状态
bean使用 singleton 作用域。
下面的图表说明了Spring原型范围:

image

(A data access object (DAO) is not typically configured as a prototype, because a typical DAO does not hold any conversational state. It was easier for us to reuse the core of the singleton diagram.)
The following example defines a bean as a prototype in XML:


(数据访问对象(DAO)通常不配置为 prototype,因为典型的DAO不持有任何会话状态。
重用 singleton 图的核心对我们来说更容易。)
下面的例子,在XML文件中将bean定义为prototype 类型:
<bean id="accountService" class="com.something.DefaultAccountService" scope="prototype"/>

In contrast to the other scopes, Spring does not manage the complete lifecycle of a prototype bean. The container instantiates, configures, and otherwise assembles a prototype object and hands it to the client, with no further record of that prototype instance. Thus, although initialization lifecycle callback methods are called on all objects regardless of scope, in the case of prototypes, configured destruction lifecycle callbacks are not called. The client code must clean up prototype-scoped objects and release expensive resources that the prototype beans hold. To get the Spring container to release resources held by prototype-scoped beans, try using a custom bean post-processor, which holds a reference to beans that need to be cleaned up.

与其他作用域相比,Spring不管理 prototype 类型bean的完整生命周期。
容器实例化、配置和组装原型对象并将其交给客户端,而不进一步记录该原型实例。
因此,尽管所有对象的初始化生命周期回调方法都被调用,但prototype bean,
配置的销毁生命周期回调不会被调用。
客户端代码必须清理 prototype 的对象并释放 prototype bean所持有的珍贵资源。
要让Spring容器释放 prototype 作用域bean所持有的资源,请尝试使用
自定义bean 的post-processor方法,它持有对需要清理的bean的引用。

In some respects, the Spring container’s role in regard to a prototype-scoped bean is a replacement for the Java new operator. All lifecycle management past that point must be handled by the client. (For details on the lifecycle of a bean in the Spring container, see Lifecycle Callbacks.)

某种意义上来说,对于 prototype 作用域bean的Spring容器角色是Java new
操作符的替代品。
超过这个时间点的所有生命周期管理都必须由客户处理。
(有关Spring容器中bean生命周期的详细信息,请参见生命周期回调。)

1.5.3. Singleton Beans with Prototype-bean Dependencies

1.5.3. Singleton作用域的bean引用 Prototype作用域的bean

When you use singleton-scoped beans with dependencies on prototype beans, be aware that dependencies are resolved at instantiation time. Thus, if you dependency-inject a prototype-scoped bean into a singleton-scoped bean, a new prototype bean is instantiated and then dependency-injected into the singleton bean. The prototype instance is the sole instance that is ever supplied to the singleton-scoped bean.

当您使用带有 prototype bean依赖项的 Singleton 作用域的bean时,请注意依赖项
是在实例化时解析的。
因此,如果您将 prototype 作用域的bean依赖注入到 Singleton 作用域的bean中,
那么将实例化一个新的 prototype bean,然后依赖地注入到 Singleton bean中。
prototype 实例是提供给 Singleton 作用域bean的唯一实例。

However, suppose you want the singleton-scoped bean to acquire a new instance of the prototype-scoped bean repeatedly at runtime. You cannot dependency-inject a prototype-scoped bean into your singleton bean, because that injection occurs only once, when the Spring container instantiates the singleton bean and resolves and injects its dependencies. If you need a new instance of a prototype bean at runtime more than once, see Method Injection(https://docs.spring.io/spring/docs/5.2.7.RELEASE/spring-framework-reference/core.html#beans-factory-method-injection)

但是,假设您希望 Singleton 作用域bean在运行时重复获得 prototype 作用域bean
的新实例。
您不能将 prototype 作用域的bean依赖注入到 Singleton bean中,因为该注入
只在Spring容器实例化 Singleton bean并解析和注入其依赖项时发生一次。
如果您不止一次地需要 prototype bean在运行时的新实例,请参阅方法注入。

1.5.4. Request, Session, Application, and WebSocket Scopes

1.5.4. Request, Session, Application, and WebSocket 作用域

The request, session, application, and websocket scopes are available only if you use a web-aware Spring ApplicationContext implementation (such as XmlWebApplicationContext). If you use these scopes with regular Spring IoC containers, such as the ClassPathXmlApplicationContext, an IllegalStateException that complains about an unknown bean scope is thrown.

请求、会话、应用程序和websocket作用域只有在使用web 的
Spring ApplicationContext实现(如XmlWebApplicationContext)时才可用。
如果您将这些作用域与常规的Spring IoC容器(如ClassPathXmlApplicationContext)
一起使用,则会抛出一个IllegalStateException,该异常报告一个未知的bean作用域。
Initial Web Configuration
初始化网络配置

To support the scoping of beans at the request, session, application, and websocket levels (web-scoped beans), some minor initial configuration is required before you define your beans. (This initial setup is not required for the standard scopes: singleton and prototype.)

为了在request, session, application, websocket级别(web作用域bean)上
支持bean的作用域,在定义bean之前需要进行一些小的初始配置。
(这个初始化设置对于标准范围: singleton 和 prototype 来说不是必需的。)

How you accomplish this initial setup depends on your particular Servlet environment.

如何完成这个初始化设置取决于特定的Servlet环境。

If you access scoped beans within Spring Web MVC, in effect, within a request that is processed by the Spring DispatcherServlet, no special setup is necessary. DispatcherServlet already exposes all relevant state.
If you use a Servlet 2.5 web container, with requests processed outside of Spring’s DispatcherServlet (for example, when using JSF or Struts), you need to register the org.springframework.web.context.request.RequestContextListener ServletRequestListener. For Servlet 3.0+, this can be done programmatically by using the WebApplicationInitializer interface. Alternatively, or for older containers, add the following declaration to your web application’s web.xml file

如果您在Spring Web MVC中访问范围限定的bean
(实际上是在由Spring DispatcherServlet处理的请求中访问),
则不需要进行特殊设置。
DispatcherServlet已经公开了所有相关状态。
如果您使用Servlet 2.5 web容器,并且请求是在Spring的DispatcherServlet之外处理的
(例如,在使用JSF或Struts时),那么您需要注册org.springframework.web.context.request.RequestContextListener 作为ServletRequestListener。
对于Servlet 3.0+,这可以通过使用WebApplicationInitializer接口以编程方式完成。
或者对于较旧的容器,将以下声明添加到web应用程序的web.xml文件中
<web-app>... <listener> <listener-class> org.springframework.web.context.request.RequestContextListener </listener-class> </listener> ... 
</web-app>

Alternatively, if there are issues with your listener setup, consider using Spring’s RequestContextFilter. The filter mapping depends on the surrounding web application configuration, so you have to change it as appropriate. The following listing shows the filter part of a web application:

另外,如果侦听器设置存在问题,可以考虑使用Spring的RequestContextFilter。
filter mapping取决于web应用程序配置环境,因此您必须适当地更改它。
下面的清单显示了web应用程序的filter部分:
<web-app>... <filter><filter-name>requestContextFilter</filter-name> <filter-class>org.springframework.web.filter.RequestContextFilter</filter-class> </filter> <filter-mapping> <filter-name>requestContextFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>... 
</web-app>

DispatcherServlet, RequestContextListener, and RequestContextFilter all do exactly the same thing, namely bind the HTTP request object to the Thread that is servicing that request. This makes beans that are request- and session-scoped available further down the call chain.

DispatcherServlet、RequestContextListener和RequestContextFilter
都执行完全相同的操作,也就是将HTTP请求对象绑定到为该请求提供服务的线程。
这使得作用域为 request 和 session 的bean在调用链的更深处可用。
Request scope
Request作用域

Consider the following XML configuration for a bean definition:

考虑以下针对bean定义的XML配置:
<bean id="loginAction" class="com.something.LoginAction" scope="request"/>

The Spring container creates a new instance of the LoginAction bean by using the loginAction bean definition for each and every HTTP request. That is, the loginAction bean is scoped at the HTTP request level. You can change the internal state of the instance that is created as much as you want, because other instances created from the same loginAction bean definition do not see these changes in state. They are particular to an individual request. When the request completes processing, the bean that is scoped to the request is discarded.:

Spring容器为每个HTTP请求使用LoginAction bean定义,从而创建
LoginAction bean的一个新实例。
也就是说,loginAction bean的作用域在HTTP请求级别。
您可以随意更改所创建实例的内部状态,因为从相同loginAction bean definition 
创建的其他实例不会看到这些状态更改。
它们是针对个别请求的。当请求完成处理时,作用于该请求的bean被丢弃。

When using annotation-driven components or Java configuration, the @RequestScope annotation can be used to assign a component to the request scope. The following example shows how to do so:

当使用注释驱动的组件或Java配置时,可以使用@RequestScope注释将组件分配
到请求范围。
下面的例子展示了如何做到这一点:

@RequestScope 
@Component 
public class LoginAction { // ... 
}
Session Scope
Session 作用域

Consider the following XML configuration for a bean definition:

考虑以下针对bean definition 的XML配置:
<bean id="userPreferences" class="com.something.UserPreferences" scope="session"/>

The Spring container creates a new instance of the UserPreferences bean by using the userPreferences bean definition for the lifetime of a single HTTP Session. In other words, the userPreferences bean is effectively scoped at the HTTP Session level. As with request-scoped beans, you can change the internal state of the instance that is created as much as you want, knowing that other HTTP Session instances that are also using instances created from the same userPreferences bean definition do not see these changes in state, because they are particular to an individual HTTP Session. When the HTTP Session is eventually discarded, the bean that is scoped to that particular HTTP Session is also discarded.

Spring容器通过使用单个HTTP session生存期的UserPreferences bean
定义来创建一个UserPreferences bean的新实例。
换句话说,userPreferences bean有效地限定了HTTP session 级别的范围。
与request 作用域bean一样,你可以尽可能多地按照你想要的方式改变创建
实例内部状态,因为我们知道其他HTTP session 实例也使用相同的 
userPreferences bean definition来创建实例,这些实例看不到这些变化状态,
因为他们是特定于独立的HTTP session。
当最终丢弃HTTP session 时,作用域为该特定HTTP session的bean也将被丢弃。

When using annotation-driven components or Java configuration, you can use the @SessionScope annotation to assign a component to the session scope.

在使用注释驱动的组件或Java配置时,可以使用@SessionScope注释将组件
分配给会话范围。

@SessionScope
@Component
public class UserPreferences {// ...
}
Application Scope
Application 作用域

Consider the following XML configuration for a bean definition:

考虑以下针对bean定义的XML配置:
<bean id="appPreferences" class="com.something.AppPreferences" scope="application"/>

The Spring container creates a new instance of the AppPreferences bean by using the appPreferences bean definition once for the entire web application. That is, the appPreferences bean is scoped at the ServletContext level and stored as a regular ServletContext attribute. This is somewhat similar to a Spring singleton bean but differs in two important ways: It is a singleton per ServletContext, not per Spring ‘ApplicationContext’ (for which there may be several in any given web application), and it is actually exposed and therefore visible as a ServletContext attribute.

Spring容器为整个web应用程序使用一次AppPreferences bean定义,
从而创建AppPreferences bean的新实例。
也就是说,appPreferences bean的作用域在ServletContext级别,
并存储为一个常规的ServletContext属性。
这有点类似于 Spring singleton bean,但在两个重要方面不同:它是
每一个ServletContext有一个singleton,
不是每一个Spring ApplicationContext一个
(可能有几个在任何给定的web应用程序),它实际上是公开的,
因此作为ServletContext属性可见。

When using annotation-driven components or Java configuration, you can use the @ApplicationScope annotation to assign a component to the application scope. The following example shows how to do so:

当使用注释驱动的组件或Java配置时,您可以使用@ApplicationScope
注释来为 application 作用域分配一个组件。
下面的例子展示了如何做到这一点:
@ApplicationScope
@Component
public class AppPreferences {// ...
}
Scoped Beans as Dependencies
将限定范围的bean作为依赖项

The Spring IoC container manages not only the instantiation of your objects (beans), but also the wiring up of collaborators (or dependencies). If you want to inject (for example) an HTTP request-scoped bean into another bean of a longer-lived scope, you may choose to inject an AOP proxy in place of the scoped bean. That is, you need to inject a proxy object that exposes the same public interface as the scoped object but that can also retrieve the real target object from the relevant scope (such as an HTTP request) and delegate method calls onto the real object.

Spring IoC容器不仅管理对象(bean)的实例化,还管理协作者(或依赖项)的连接。
如果您想将(例如)一个HTTP request 作用域的bean注入到另一个更长生命周期
作用域的bean中,您可以选择注入一个AOP代理来代替作用域bean。
也就是说,您需要注入一个代理对象,该代理对象公开与作用域对象相同的公共接口,
但也可以从相关作用域检索实际目标对象(例如HTTP请求),并将方法调用委托给实际对象。

You may also use aop:scoped-proxy/ between beans that are scoped as singleton, with the reference then going through an intermediate proxy that is serializable and therefore able to re-obtain the target singleton bean on deserialization.

你也可以使用 <aop:scoped-proxy/> 标签,在作用域为 singleton bean之间进行引用,
然后通过一个中间代理进行引用,该代理是可序列化的,因此能够在反序列化时
重新获得目标单例bean。

When declaring aop:scoped-proxy/ against a bean of scope prototype, every method call on the shared proxy leads to the creation of a new target instance to which the call is then being forwarded.

当对作用域 prototype bean 声明  <aop:scoped-proxy/>标签 ,
对共享代理的每个方法调用都会创建一个新的目标实例,
然后将调用转发到该目标实例。

Also, scoped proxies are not the only way to access beans from shorter scopes in a lifecycle-safe fashion. You may also declare your injection point (that is, the constructor or setter argument or autowired field) as ObjectFactory, allowing for a getObject() call to retrieve the current instance on demand every time it is needed — without holding on to the instance or storing it separately.

此外,作用域代理并不是以生命周期安全的方式从更短的作用域访问bean的唯一方法。
你也可以声明你的注入点(也就是构造函数或setter参数或autowired的字段)
ObjectFactory <MyTargetBean> 允许getObject()调用来检索当前实例对
需求每次需要——没有分别持有实例或存储它。

As an extended variant, you may declare ObjectProvider, which delivers several additional access variants, including getIfAvailable and getIfUnique.

作为扩展变量,您可以声明 ObjectProvider<MyTargetBean>,
它提供了几个额外的访问变量,包括getIfAvailable和getIfUnique。

The JSR-330 variant of this is called Provider and is used with a Provider declaration and a corresponding get() call for every retrieval attempt. See here for more details on JSR-330 overall.(https://docs.spring.io/spring/docs/5.2.7.RELEASE/spring-framework-reference/core.html#beans-standard-annotations)

它的JSR-330变种称为提供者,并与提供者一起使用。声明,
并对每次检索尝试进行相应的get()调用。关于JSR-330的更多详细信息请参见这里。

The configuration in the following example is only one line, but it is important to understand the “why” as well as the “how” behind it:

下面例子中的只有一行配置,但是理解它背后的“为什么”和“如何”是很重要的:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:aop="http://www.springframework.org/schema/aop"xsi:schemaLocation="http://www.springframework.org/schema/beanshttps://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/aophttps://www.springframework.org/schema/aop/spring-aop.xsd"><!-- an HTTP Session-scoped bean exposed as a proxy --><bean id="userPreferences" class="com.something.UserPreferences" scope="session"><!-- instructs the container to proxy the surrounding bean --><aop:scoped-proxy/>  1 </bean><!-- a singleton-scoped bean injected with a proxy to the above bean --><bean id="userService" class="com.something.SimpleUserService"><!-- a reference to the proxied userPreferences bean --><property name="userPreferences" ref="userPreferences"/></bean>
</beans>

1 The line that defines the proxy.

定义代理的行。

To create such a proxy, you insert a child aop:scoped-proxy/ element into a scoped bean definition (see Choosing the Type of Proxy to Create and XML Schema-based configuration). Why do definitions of beans scoped at the request, session and custom-scope levels require the aop:scoped-proxy/ element? Consider the following singleton bean definition and contrast it with what you need to define for the aforementioned scopes (note that the following userPreferences bean definition as it stands is incomplete):

要创建这样的代理,需要向bean definition插入一个子元素<aop:scoped-proxy/> 
(请参阅章节 - 选择要创建的代理类型和基于XML模式的配置)。
为什么在request, session 和 custom-scope作用域级别定义bean需要
<aop:scoped-proxy/>元素?
考虑下面的 singleton bean定义,并将其与您需要为上述范围定义的对象进行对比
(注意,下面的userPreferences bean definition 是不完整的):
<bean id="userPreferences" class="com.something.UserPreferences" scope="session"/><bean id="userManager" class="com.something.UserManager"><property name="userPreferences" ref="userPreferences"/>
</bean>

In the preceding example, the singleton bean (userManager) is injected with a reference to the HTTP Session-scoped bean (userPreferences). The salient point here is that the userManager bean is a singleton: it is instantiated exactly once per container, and its dependencies (in this case only one, the userPreferences bean) are also injected only once. This means that the userManager bean operates only on the exact same userPreferences object (that is, the one with which it was originally injected.

在前面的示例中,singleton bean (userManager)被注入到了HTTP session 
作用域bean (userPreferences)的引用。
这里要关注的要点是userManager bean是singleton 类型:每个容器只实例化一次,
它的依赖项(在本例中只有一个,即userPreferences bean)也只被注入一次。
这意味着userManager bean只操作完全相同的userPreferences对象
(即最初注入它的对象)。

This is not the behavior you want when injecting a shorter-lived scoped bean into a longer-lived scoped bean (for example, injecting an HTTP Session-scoped collaborating bean as a dependency into singleton bean). Rather, you need a single userManager object, and, for the lifetime of an HTTP Session, you need a userPreferences object that is specific to the HTTP Session. Thus, the container creates an object that exposes the exact same public interface as the UserPreferences class (ideally an object that is a UserPreferences instance), which can fetch the real UserPreferences object from the scoping mechanism (HTTP request, Session, and so forth). The container injects this proxy object into the userManager bean, which is unaware that this UserPreferences reference is a proxy. In this example, when a UserManager instance invokes a method on the dependency-injected UserPreferences object, it is actually invoking a method on the proxy. The proxy then fetches the real UserPreferences object from (in this case) the HTTP Session and delegates the method invocation onto the retrieved real UserPreferences object.

当将较短的作用域bean注入到较长作用域bean中时
(例如,将HTTP session作用域的协作bean作为依赖项注入到 singleton bean中),
这不是您想要的行为。
相反,您需要一个userManager对象,并且在HTTP session 的生命周期中,
您需要一个特定于HTTP session 的userPreferences对象。
因此,容器创建一个对象,该对象公开与UserPreferences类完全相同的公共接口
(理想情况下,该对象是一个UserPreferences实例),
它可以从作用域机制(HTTP request、session 等)获取真正的UserPreferences对象。
容器将这个代理对象注入到userManager bean中,
该bean不知道这个UserPreferences引用是一个代理。
在这个例子中,当UserManager实例调用依赖注入的UserPreferences对象上的方法时,
它实际上是调用代理上的方法。
代理然后从(在本例中)HTTP session中获取真实的UserPreferences对象,
并将方法调用委托给检索到的真实UserPreferences对象。

Thus, you need the following (correct and complete) configuration when injecting request- and session-scoped beans into collaborating objects, as the following example shows:

因此,当将 request 和 session 作用域的bean注入到协作对象中时,
您需要以下(正确和完整的)配置,如下面的示例所示:
<bean id="userPreferences" class="com.something.UserPreferences" scope="session"><aop:scoped-proxy/>
</bean><bean id="userManager" class="com.something.UserManager"><property name="userPreferences" ref="userPreferences"/>
</bean>
Choosing the Type of Proxy to Create
选择要创建的代理类型

By default, when the Spring container creates a proxy for a bean that is marked up with the aop:scoped-proxy/ element, a CGLIB-based class proxy is created.

默认情况下,当Spring容器为用<aop:scoped-proxy/>标记的bean创建代理时,
元素,则创建一个基于cglib的类代理。

CGLIB proxies intercept only public method calls! Do not call non-public methods on such a proxy. They are not delegated to the actual scoped target object.

CGLIB代理仅拦截公共方法调用!不要在这样的代理上调用非公共方法。
它们没有被委托给实际作用域的目标对象。

Alternatively, you can configure the Spring container to create standard JDK interface-based proxies for such scoped beans, by specifying false for the value of the proxy-target-class attribute of the aop:scoped-proxy/ element. Using JDK interface-based proxies means that you do not need additional libraries in your application classpath to affect such proxying. However, it also means that the class of the scoped bean must implement at least one interface and that all collaborators into which the scoped bean is injected must reference the bean through one of its interfaces. The following example shows a proxy based on an interface:

或者,您可以配置Spring容器为这种作用域bean创建标准的基于JDK接口的代理,
方法是将 <aop:scoped-proxy/> 属性的值指定为false。
使用JDK基于接口的代理意味着您不需要在应用程序类路径中添加其他库来生成这种代理。
然而,这也意味着作用域bean的类必须实现至少一个接口,
并且所有注入作用域bean的协作者必须通过它的一个接口引用该bean。
下面的例子显示了一个基于接口的代理:
<!-- DefaultUserPreferences implements the UserPreferences interface -->
<bean id="userPreferences" class="com.stuff.DefaultUserPreferences" scope="session"><aop:scoped-proxy proxy-target-class="false"/>
</bean><bean id="userManager" class="com.stuff.UserManager"><property name="userPreferences" ref="userPreferences"/>
</bean>

For more detailed information about choosing class-based or interface-based proxying, see Proxying Mechanisms.(https://docs.spring.io/spring/docs/5.2.7.RELEASE/spring-framework-reference/core.html#aop-proxying)

有关选择基于类或基于接口的代理的详细信息,请参阅代理机制。

1.5.5. Custom Scopes

自定义作用域

The bean scoping mechanism is extensible. You can define your own scopes or even redefine existing scopes, although the latter is considered bad practice and you cannot override the built-in singleton and prototype scopes.

bean作用域机制是可扩展的。您可以定义自己的作用域,
甚至可以重新定义现有的作用域,尽管后者被认为是不好的做法,
而且您不能覆盖内置的singleton和prototype作用域。
Creating a Custom Scope
创建自定义作用域

To integrate your custom scopes into the Spring container, you need to implement the org.springframework.beans.factory.config.Scope interface, which is described in this section. For an idea of how to implement your own scopes, see the Scope implementations that are supplied with the Spring Framework itself and the Scope javadoc, which explains the methods you need to implement in more detail.

要将您的自定义作用域集成到Spring容器中,您需要实现org.springframework.bean.factory.config.Scope接口,这将在本节中描述。
要了解如何实现自己的作用域,请参阅随Spring框架本身提供的作用域实现和作用域javadoc,
后者详细解释了需要实现的方法。

The Scope interface has four methods to get objects from the scope, remove them from the scope, and let them be destroyed.

Scope接口有四个方法,用于从范围中获取对象、从范围中删除对象以及销毁它们。

The session scope implementation, for example, returns the session-scoped bean (if it does not exist, the method returns a new instance of the bean, after having bound it to the session for future reference). The following method returns the object from the underlying scope:

例如,session 作用域的实现返回 session 作用域bean(如果它不存在,
该方法将bean的一个新实例绑定到session 以供将来引用)。
下面的方法从底层范围返回对象:
Object get(String name, ObjectFactory<?> objectFactory)

The session scope implementation, for example, removes the session-scoped bean from the underlying session. The object should be returned, but you can return null if the object with the specified name is not found. The following method removes the object from the underlying scope:

例如,session 作用域实现从基础 session 中删除session 作用域bean。
应该返回该对象,但如果没有找到具有指定名称的对象,则可以返回null。
下面的方法将对象从底层范围中移除:
Object remove(String name)

The following method registers the callbacks the scope should execute when it is destroyed or when the specified object in the scope is destroyed:

下面的方法注册了作用域在销毁或作用域中指定对象销毁时应该执行的回调函数:
void registerDestructionCallback(String name, Runnable destructionCallback)

See the javadoc or a Spring scope implementation for more information on destruction callbacks.
The following method obtains the conversation identifier for the underlying scope:

有关销毁回调的更多信息,请参阅javadoc或Spring作用域实现。
下面的方法获取底层范围的对话标识符:
String getConversationId()

This identifier is different for each scope. For a session scoped implementation, this identifier can be the session identifier.

这个标识符对于每个范围都是不同的。
对于会话范围的实现,此标识符可以是会话标识符。
Using a Custom Scope
使用自定义作用域

After you write and test one or more custom Scope implementations, you need to make the Spring container aware of your new scopes. The following method is the central method to register a new Scope with the Spring container:

在编写和测试一个或多个自定义作用域实现之后,
您需要让Spring容器知道您的新作用域。
下面的方法是向Spring容器注册新范围的中心方法:
void registerScope(String scopeName, Scope scope);

This method is declared on the ConfigurableBeanFactory interface, which is available through the BeanFactory property on most of the concrete ApplicationContext implementations that ship with Spring.

此方法在ConfigurableBeanFactory接口上声明,
该接口通过Spring ApplicationContext实现类的BeanFactory属性可用。

The first argument to the registerScope(…) method is the unique name associated with a scope. Examples of such names in the Spring container itself are singleton and prototype. The second argument to the registerScope(…) method is an actual instance of the custom Scope implementation that you wish to register and use.

registerScope(..)方法的第一个参数是与作用域关联的惟一名称。
此类名称在Spring容器本身中的例子有singleton和prototype。
registerScope(..)方法的第二个参数是您希望注册和使用的自定义范围实现的一个实际实例。

Suppose that you write your custom Scope implementation, and then register it as shown in the next example.
The next example uses SimpleThreadScope, which is included with Spring but is not registered by default. The instructions would be the same for your own custom Scope implementations.

假设您编写了自定义范围实现,然后注册它,如下一个示例所示。
下一个示例使用SimpleThreadScope,它包含在Spring中,但默认情况下没有注册。
对于您自己的自定义范围实现,说明是相同的。
Scope threadScope = new SimpleThreadScope();
beanFactory.registerScope("thread", threadScope);

You can then create bean definitions that adhere to the scoping rules of your custom Scope, as follows:

然后,您可以创建遵循自定义范围的范围规则的 bean definitions ,如下所示:
<bean id="..." class="..." scope="thread">

With a custom Scope implementation, you are not limited to programmatic registration of the scope. You can also do the Scope registration declaratively, by using the CustomScopeConfigurer class, as the following example shows:

使用自定义范围实现,您不必局限于对范围的编程式注册。
您还可以通过使用CustomScopeConfigurer类声明性地进行范围注册,
如下面的示例所示:
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:aop="http://www.springframework.org/schema/aop"xsi:schemaLocation="http://www.springframework.org/schema/beanshttps://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/aophttps://www.springframework.org/schema/aop/spring-aop.xsd"><bean class="org.springframework.beans.factory.config.CustomScopeConfigurer"><property name="scopes"><map><entry key="thread"><bean class="org.springframework.context.support.SimpleThreadScope"/></entry></map></property></bean><bean id="thing2" class="x.y.Thing2" scope="thread"><property name="name" value="Rick"/><aop:scoped-proxy/></bean><bean id="thing1" class="x.y.Thing1"><property name="thing2" ref="thing2"/></bean></beans>

When you place aop:scoped-proxy/ in a FactoryBean implementation, it is the factory bean itself that is scoped, not the object returned from getObject().

当你在FactoryBean实现中设置<aop:scoped-proxy/>,作用域是工厂bean本身,
而不是getObject()返回的对象。
查看全文
如若内容造成侵权/违法违规/事实不符,请联系编程学习网邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!

相关文章

  1. 3DSlicer相关资料汇总

    1. 官网:https://www.slicer.org/2. 中文论坛:https://slicercn.com/?page_id=4082...

    2024/4/16 5:53:44
  2. 找一份好工作才是你人生的转折点!

    你是否还在整日碌碌无为的读书,然而什么也没有学进去,就这样恍恍惚惚的度过了三年,你不像别人那样考研,转升本,可能你会觉得毕业之后反正都会找到工作的,有工作就行,但是,找工作容易,找好工作很难。 有多少人大学毕业之后,找不到工作,自己学的不好,也没能力找到自己…...

    2024/4/16 5:53:44
  3. H. Palindromic Cut(思维,分类暴力)

    感觉自己思路还行,分类也很清晰 直接枚举每个回文串最大的长度i,从n枚举到1 设输入的字符为奇数的有ji个,命名为设输入的字符为奇数的有ji个,命名为设输入的字符为奇数的有ji个,命名为奇数字符 否则命名为偶数字符 Ⅰ.显然,n%i==0Ⅰ.显然,n\%i==0Ⅰ.显然,n%i==0 Ⅱ.当i是偶数,那…...

    2024/4/20 12:53:25
  4. bigWigToBedGraph格式转换

    !!!!记得把下载的bigWigToBedGraph 加上chmod 755 bw转bedgraph 转 bed 转其他 都可以的 http://hgdownload.soe.ucsc.edu/admin/exe/linux.x86_64/================================================================ ======== bigWigToBedGraph ====================…...

    2024/4/16 5:53:44
  5. 使用git时出现的问题

    1、git push -u origin master出现 Updates were rejected because the remote contains work that you do原因:本地repository和远程repository中文件有被修改发生冲突需要合并 解决: 本以为可以解决了 于是执行git push -u origin master 又出现错误,见下2 2、git push -u…...

    2024/4/19 8:26:00
  6. 【蓝桥杯】2015决赛 穿越雷区(bfs)

    题目描述 X星的坦克战车很奇怪,它必须交替地穿越正能量辐射区和负能量辐射区才能保持正常运转,否则将报废。 某坦克需要从A区到B区去(A,B区本身是安全区,没有正能量或负能量特征),怎样走才能路径最短? 已知的地图是一个方阵,上面用字母标出了A,B区,其它区都标了正号…...

    2024/4/16 5:54:45
  7. 看完这篇自己都可以写Spring IOC 容器 Bean 对象实例化--乐字节java

    Spring IOC 容器 Bean 对象实例化模拟 思路:定义Bean 工厂接口,提供获取bean方法 定义Bean工厂接口实现类,解析配置文件,实例化Bean对象 实现获取Bean方法定义 Bean 属性对象 package com.xxxx.spring;/*** bean对象* 用来接收配置文件中bean标签的id与class属性值*/ p…...

    2024/4/16 5:54:15
  8. Java放弃之旅(三)-操作符

    可能会困扰你的小问题合集 1.“=”对象之间的赋值操作实际上是引用的复制,被赋值的对象将会丢失原有的引用,原有的引用对象将会被垃圾回收器回收 可以使用数据成员赋值取代对象的赋值,以便对象之间能够保持相互独立// t1=t2 t1.value=t2.value;方法调用时也会出现上述的赋值…...

    2024/4/16 5:54:45
  9. Redis简明教程

    https://zhuanlan.zhihu.com/p/37055648Redis简明教程柳树公众号:柳树的絮叨叨373 人赞同了该文章Redis是啥?用Redis官方的话来说就是:Redis is an open source (BSD licensed), in-memory data structure store, used as a database, cache and message broker.Redis是一个…...

    2024/4/16 5:54:40
  10. Focussend:用户生命周期价值与企业营销自动化

    编辑:DM校对:MoMo出处:Focussend近几年,CLV的概念被各大B2B\B2C公司疯狂提及,其实该理论在上世纪80年代就已经提出,最近传统企业才开始关注CLV,可能因为当下内外各种因素,造成企业用户增长困难,因而企业纷纷聚焦以“用户”为中心的新营销方式。但长期以来,企业对客户…...

    2024/4/1 2:20:35
  11. BCIduino社区航弈实验室32通道脑电放大器位置表

    BCIduino社区航弈实验室32通道脑电放大器位置表第一组: 1.Fp1 2.F3 3.F7 4.Fz 5.Fcz 6.Fp2 7.F4 8.F8 9.GND 10.REF 第二组: 1.FT7 2.FC3 3.C1 4.C3 5.T3 6.CPZ 7.CP3 8.TP7 9.GND 10.REF 第三组: 1.FC4 2.FT8 3.CZ 4.C2 5.C4 6.T4 7.CP4 8.TP8 9.GND 10.REF 第四组: 1.PZ …...

    2024/4/1 2:20:34
  12. 第2部分 字符串算法(提高篇)--第1章 哈希和哈希表1458:Seek the Name, Seek the Fame

    1458:Seek the Name, Seek the Fame 时间限制: 1000 ms 内存限制: 65536 KB 提交数: 641 通过数: 337 【题目描述】 原题来自:POJ 2752 给定若干字符串(这些字符串总长 ≤4105​​ ),在每个字符串中求出所有既是前缀又是后缀的子串长度。 例如:ababcabababab…...

    2024/4/18 11:09:32
  13. swagger在oauth统一认证中报错401 Unauthorized

    在项目进行开发的时候搭建的swagger访问http://localhost:8080/swagger-ui.html发现springCloud搭建的oauth统一认证的框架中Unauthorized 401明显就是授权认证没有token问题。接口文档swagger其实可以不需要认证,只是开发者在开发环境使用。1、要么添加固有认证token在系统中…...

    2024/4/1 2:20:34
  14. 细说环境变量

    细说环境变量一句话说明环境变量环境变量位置为什么会有%JAVA_HOME%这样的字符串?为什么是%JAVA_HOME%这样的字符串总结 一句话说明环境变量 我们通过设置环境变量,来更好的运行进程。 比如JAVA/MYSQL等 环境变量位置 以win10为例,“我的电脑”右键-“高级系统设置”-“环境…...

    2024/4/16 5:54:35
  15. Java : 子集和问题

    子集和问题的一个实例为〈S,t〉。其中,S={ 1 x , 2 x ,…, n x }是一个常数的集合,c是一个常数。子集和问题判定是否存在S的一个子集S1,使得 S1中的所有元素之和等于c。 常熟集合为请求参数List<Double>,targetNumber为目标常数c笨办法就是列举,假如有五个数1,2,…...

    2024/4/16 5:53:29
  16. 基于Spring Boot的WebSocket聊天室DEMO

    参考以下文章完成的最小DEMO: https://www.baeldung.com/websockets-spring 解决了前端跨域问题,使用cdn网站在线js资源,无需自行下载sockJS和stompJS,具体运行效果如下: 代码地址:https://github.com/2016LMS/WebSocket 运行步骤: 1.导入IDEA,将pom.xml交由maven管理,…...

    2024/4/20 14:46:02
  17. mysql : 使用不等于过滤null的问题

    在写SQL 条件语句是经常用到 不等于‘!=’的筛选条件,此时要注意此条件会将字段为null的数据也当做满足不等于的条件而将数据筛选掉。例:表A用 select * from A where B1 != 1查询时得到的结果为:第三列 B1为空的也是会筛选掉的。因为 NULL 不是一个「值」,而是「没有值」。…...

    2024/4/16 5:54:30
  18. (全) flex布局兼容性 兼容新老浏览器、移动端浏览器

    大部分开发者使用flex布局基本上都遇到过兼容性的问题,尤其是移动端在适配低版本的时候,下面是我总结的flex 布局兼容性的css样式,希望能帮到大家。 /* 父元素-flex容器 */ .flex{display: flex;display: -moz-box; /* Firefox 17- */ display: -webkit-flex; /* Chrome 21…...

    2024/4/16 5:54:20
  19. linux 自带的监控系统 Cockpit 系统监控

    1.基本介绍 Cockpit是一个交互式Linux服务器管理接口 、开源的基于web的管理工具,系统管理员可以执行诸如存储管理、网络配置、检查日志、管理容器等任务。通过Cockpit提供的友好的 Web 前端界面可以轻松地管理我们的 GNU/Linux 服务器,非常轻量级,Web 界面也非常简单易用…...

    2024/4/19 14:35:14
  20. 数据分析基础教程 (2)

    文章目录MatplotlibSeabornSeaborn 的主题管理Seaborn 的调色板Seaborn 分布图Scipy 基础教程回归分析插值 Matplotlib Matplotlib是Python绘图的始祖。现阶段的大部分高级绘图包如 Seaborn、holoviews、ggplot及 Pandas中的 plot()函数等都是基于 Matplotlib 定制的。换而言之…...

    2024/4/16 5:54:40

最新文章

  1. CSS基础:盒子模型详解

    你好&#xff0c;我是云桃桃。 一个希望帮助更多朋友快速入门 WEB 前端的程序媛。 云桃桃&#xff0c;大专生&#xff0c;一枚程序媛&#xff0c;感谢关注。回复 “前端基础题”&#xff0c;可免费获得前端基础 100 题汇总&#xff0c;回复 “前端工具”&#xff0c;可获取 We…...

    2024/4/20 18:57:50
  2. 梯度消失和梯度爆炸的一些处理方法

    在这里是记录一下梯度消失或梯度爆炸的一些处理技巧。全当学习总结了如有错误还请留言&#xff0c;在此感激不尽。 权重和梯度的更新公式如下&#xff1a; w w − η ⋅ ∇ w w w - \eta \cdot \nabla w ww−η⋅∇w 个人通俗的理解梯度消失就是网络模型在反向求导的时候出…...

    2024/3/20 10:50:27
  3. DDIM,多样性与运行效率之间的trade off

    DDPM的重大缺陷在于其在反向扩散的过程中需要逐步从 x t x_t xt​倒推到 x 0 x_0 x0​&#xff0c;因此其推理速度非常缓慢。相反&#xff0c;DDPM的训练过程是很快的&#xff0c;可以直接根据 x 0 x_0 x0​到 x t x_t xt​添加的高斯噪声 ϵ \epsilon ϵ完成一次训练。 为了解…...

    2024/4/18 20:00:54
  4. ARM FVP平台的terminal窗口大小如何设置

    当启动ARM FVP平台时&#xff0c;terminal窗口太小怎么办&#xff1f;看起来非常累眼睛&#xff0c;本博客来解决这个问题。 首先看下ARM FVP平台对Host主机的需求&#xff1a; 通过上图可知&#xff0c;UART默认使用的是xterm。因此&#xff0c;我们需要修改xterm的默认字体设…...

    2024/4/19 23:41:05
  5. 【外汇早评】美通胀数据走低,美元调整

    原标题:【外汇早评】美通胀数据走低,美元调整昨日美国方面公布了新一期的核心PCE物价指数数据,同比增长1.6%,低于前值和预期值的1.7%,距离美联储的通胀目标2%继续走低,通胀压力较低,且此前美国一季度GDP初值中的消费部分下滑明显,因此市场对美联储后续更可能降息的政策…...

    2024/4/19 14:24:02
  6. 【原油贵金属周评】原油多头拥挤,价格调整

    原标题:【原油贵金属周评】原油多头拥挤,价格调整本周国际劳动节,我们喜迎四天假期,但是整个金融市场确实流动性充沛,大事频发,各个商品波动剧烈。美国方面,在本周四凌晨公布5月份的利率决议和新闻发布会,维持联邦基金利率在2.25%-2.50%不变,符合市场预期。同时美联储…...

    2024/4/19 18:20:22
  7. 【外汇周评】靓丽非农不及疲软通胀影响

    原标题:【外汇周评】靓丽非农不及疲软通胀影响在刚结束的周五,美国方面公布了新一期的非农就业数据,大幅好于前值和预期,新增就业重新回到20万以上。具体数据: 美国4月非农就业人口变动 26.3万人,预期 19万人,前值 19.6万人。 美国4月失业率 3.6%,预期 3.8%,前值 3…...

    2024/4/19 11:57:31
  8. 【原油贵金属早评】库存继续增加,油价收跌

    原标题:【原油贵金属早评】库存继续增加,油价收跌周三清晨公布美国当周API原油库存数据,上周原油库存增加281万桶至4.692亿桶,增幅超过预期的74.4万桶。且有消息人士称,沙特阿美据悉将于6月向亚洲炼油厂额外出售更多原油,印度炼油商预计将每日获得至多20万桶的额外原油供…...

    2024/4/19 11:57:31
  9. 【外汇早评】日本央行会议纪要不改日元强势

    原标题:【外汇早评】日本央行会议纪要不改日元强势近两日日元大幅走强与近期市场风险情绪上升,避险资金回流日元有关,也与前一段时间的美日贸易谈判给日本缓冲期,日本方面对汇率问题也避免继续贬值有关。虽然今日早间日本央行公布的利率会议纪要仍然是支持宽松政策,但这符…...

    2024/4/19 11:57:52
  10. 【原油贵金属早评】欧佩克稳定市场,填补伊朗问题的影响

    原标题:【原油贵金属早评】欧佩克稳定市场,填补伊朗问题的影响近日伊朗局势升温,导致市场担忧影响原油供给,油价试图反弹。此时OPEC表态稳定市场。据消息人士透露,沙特6月石油出口料将低于700万桶/日,沙特已经收到石油消费国提出的6月份扩大出口的“适度要求”,沙特将满…...

    2024/4/19 11:57:53
  11. 【外汇早评】美欲与伊朗重谈协议

    原标题:【外汇早评】美欲与伊朗重谈协议美国对伊朗的制裁遭到伊朗的抗议,昨日伊朗方面提出将部分退出伊核协议。而此行为又遭到欧洲方面对伊朗的谴责和警告,伊朗外长昨日回应称,欧洲国家履行它们的义务,伊核协议就能保证存续。据传闻伊朗的导弹已经对准了以色列和美国的航…...

    2024/4/19 11:58:14
  12. 【原油贵金属早评】波动率飙升,市场情绪动荡

    原标题:【原油贵金属早评】波动率飙升,市场情绪动荡因中美贸易谈判不安情绪影响,金融市场各资产品种出现明显的波动。随着美国与中方开启第十一轮谈判之际,美国按照既定计划向中国2000亿商品征收25%的关税,市场情绪有所平复,已经开始接受这一事实。虽然波动率-恐慌指数VI…...

    2024/4/19 11:58:20
  13. 【原油贵金属周评】伊朗局势升温,黄金多头跃跃欲试

    原标题:【原油贵金属周评】伊朗局势升温,黄金多头跃跃欲试美国和伊朗的局势继续升温,市场风险情绪上升,避险黄金有向上突破阻力的迹象。原油方面稍显平稳,近期美国和OPEC加大供给及市场需求回落的影响,伊朗局势并未推升油价走强。近期中美贸易谈判摩擦再度升级,美国对中…...

    2024/4/20 7:40:48
  14. 【原油贵金属早评】市场情绪继续恶化,黄金上破

    原标题:【原油贵金属早评】市场情绪继续恶化,黄金上破周初中国针对于美国加征关税的进行的反制措施引发市场情绪的大幅波动,人民币汇率出现大幅的贬值动能,金融市场受到非常明显的冲击。尤其是波动率起来之后,对于股市的表现尤其不安。隔夜美国股市出现明显的下行走势,这…...

    2024/4/19 11:58:39
  15. 【外汇早评】美伊僵持,风险情绪继续升温

    原标题:【外汇早评】美伊僵持,风险情绪继续升温昨日沙特两艘油轮再次发生爆炸事件,导致波斯湾局势进一步恶化,市场担忧美伊可能会出现摩擦生火,避险品种获得支撑,黄金和日元大幅走强。美指受中美贸易问题影响而在低位震荡。继5月12日,四艘商船在阿联酋领海附近的阿曼湾、…...

    2024/4/19 11:58:51
  16. 【原油贵金属早评】贸易冲突导致需求低迷,油价弱势

    原标题:【原油贵金属早评】贸易冲突导致需求低迷,油价弱势近日虽然伊朗局势升温,中东地区几起油船被袭击事件影响,但油价并未走高,而是出于调整结构中。由于市场预期局势失控的可能性较低,而中美贸易问题导致的全球经济衰退风险更大,需求会持续低迷,因此油价调整压力较…...

    2024/4/20 3:12:02
  17. 氧生福地 玩美北湖(上)——为时光守候两千年

    原标题:氧生福地 玩美北湖(上)——为时光守候两千年一次说走就走的旅行,只有一张高铁票的距离~ 所以,湖南郴州,我来了~ 从广州南站出发,一个半小时就到达郴州西站了。在动车上,同时改票的南风兄和我居然被分到了一个车厢,所以一路非常愉快地聊了过来。 挺好,最起…...

    2024/4/19 11:59:15
  18. 氧生福地 玩美北湖(中)——永春梯田里的美与鲜

    原标题:氧生福地 玩美北湖(中)——永春梯田里的美与鲜一觉醒来,因为大家太爱“美”照,在柳毅山庄去寻找龙女而错过了早餐时间。近十点,向导坏坏还是带着饥肠辘辘的我们去吃郴州最富有盛名的“鱼头粉”。说这是“十二分推荐”,到郴州必吃的美食之一。 哇塞!那个味美香甜…...

    2024/4/19 11:59:23
  19. 氧生福地 玩美北湖(下)——奔跑吧骚年!

    原标题:氧生福地 玩美北湖(下)——奔跑吧骚年!让我们红尘做伴 活得潇潇洒洒 策马奔腾共享人世繁华 对酒当歌唱出心中喜悦 轰轰烈烈把握青春年华 让我们红尘做伴 活得潇潇洒洒 策马奔腾共享人世繁华 对酒当歌唱出心中喜悦 轰轰烈烈把握青春年华 啊……啊……啊 两…...

    2024/4/19 11:59:44
  20. 扒开伪装医用面膜,翻六倍价格宰客,小姐姐注意了!

    原标题:扒开伪装医用面膜,翻六倍价格宰客,小姐姐注意了!扒开伪装医用面膜,翻六倍价格宰客!当行业里的某一品项火爆了,就会有很多商家蹭热度,装逼忽悠,最近火爆朋友圈的医用面膜,被沾上了污点,到底怎么回事呢? “比普通面膜安全、效果好!痘痘、痘印、敏感肌都能用…...

    2024/4/19 11:59:48
  21. 「发现」铁皮石斛仙草之神奇功效用于医用面膜

    原标题:「发现」铁皮石斛仙草之神奇功效用于医用面膜丽彦妆铁皮石斛医用面膜|石斛多糖无菌修护补水贴19大优势: 1、铁皮石斛:自唐宋以来,一直被列为皇室贡品,铁皮石斛生于海拔1600米的悬崖峭壁之上,繁殖力差,产量极低,所以古代仅供皇室、贵族享用 2、铁皮石斛自古民间…...

    2024/4/19 12:00:06
  22. 丽彦妆\医用面膜\冷敷贴轻奢医学护肤引导者

    原标题:丽彦妆\医用面膜\冷敷贴轻奢医学护肤引导者【公司简介】 广州华彬企业隶属香港华彬集团有限公司,专注美业21年,其旗下品牌: 「圣茵美」私密荷尔蒙抗衰,产后修复 「圣仪轩」私密荷尔蒙抗衰,产后修复 「花茵莳」私密荷尔蒙抗衰,产后修复 「丽彦妆」专注医学护…...

    2024/4/19 16:57:22
  23. 广州械字号面膜生产厂家OEM/ODM4项须知!

    原标题:广州械字号面膜生产厂家OEM/ODM4项须知!广州械字号面膜生产厂家OEM/ODM流程及注意事项解读: 械字号医用面膜,其实在我国并没有严格的定义,通常我们说的医美面膜指的应该是一种「医用敷料」,也就是说,医用面膜其实算作「医疗器械」的一种,又称「医用冷敷贴」。 …...

    2024/4/19 12:00:25
  24. 械字号医用眼膜缓解用眼过度到底有无作用?

    原标题:械字号医用眼膜缓解用眼过度到底有无作用?医用眼膜/械字号眼膜/医用冷敷眼贴 凝胶层为亲水高分子材料,含70%以上的水分。体表皮肤温度传导到本产品的凝胶层,热量被凝胶内水分子吸收,通过水分的蒸发带走大量的热量,可迅速地降低体表皮肤局部温度,减轻局部皮肤的灼…...

    2024/4/19 12:00:40
  25. 配置失败还原请勿关闭计算机,电脑开机屏幕上面显示,配置失败还原更改 请勿关闭计算机 开不了机 这个问题怎么办...

    解析如下&#xff1a;1、长按电脑电源键直至关机&#xff0c;然后再按一次电源健重启电脑&#xff0c;按F8健进入安全模式2、安全模式下进入Windows系统桌面后&#xff0c;按住“winR”打开运行窗口&#xff0c;输入“services.msc”打开服务设置3、在服务界面&#xff0c;选中…...

    2022/11/19 21:17:18
  26. 错误使用 reshape要执行 RESHAPE,请勿更改元素数目。

    %读入6幅图像&#xff08;每一幅图像的大小是564*564&#xff09; f1 imread(WashingtonDC_Band1_564.tif); subplot(3,2,1),imshow(f1); f2 imread(WashingtonDC_Band2_564.tif); subplot(3,2,2),imshow(f2); f3 imread(WashingtonDC_Band3_564.tif); subplot(3,2,3),imsho…...

    2022/11/19 21:17:16
  27. 配置 已完成 请勿关闭计算机,win7系统关机提示“配置Windows Update已完成30%请勿关闭计算机...

    win7系统关机提示“配置Windows Update已完成30%请勿关闭计算机”问题的解决方法在win7系统关机时如果有升级系统的或者其他需要会直接进入一个 等待界面&#xff0c;在等待界面中我们需要等待操作结束才能关机&#xff0c;虽然这比较麻烦&#xff0c;但是对系统进行配置和升级…...

    2022/11/19 21:17:15
  28. 台式电脑显示配置100%请勿关闭计算机,“准备配置windows 请勿关闭计算机”的解决方法...

    有不少用户在重装Win7系统或更新系统后会遇到“准备配置windows&#xff0c;请勿关闭计算机”的提示&#xff0c;要过很久才能进入系统&#xff0c;有的用户甚至几个小时也无法进入&#xff0c;下面就教大家这个问题的解决方法。第一种方法&#xff1a;我们首先在左下角的“开始…...

    2022/11/19 21:17:14
  29. win7 正在配置 请勿关闭计算机,怎么办Win7开机显示正在配置Windows Update请勿关机...

    置信有很多用户都跟小编一样遇到过这样的问题&#xff0c;电脑时发现开机屏幕显现“正在配置Windows Update&#xff0c;请勿关机”(如下图所示)&#xff0c;而且还需求等大约5分钟才干进入系统。这是怎样回事呢&#xff1f;一切都是正常操作的&#xff0c;为什么开时机呈现“正…...

    2022/11/19 21:17:13
  30. 准备配置windows 请勿关闭计算机 蓝屏,Win7开机总是出现提示“配置Windows请勿关机”...

    Win7系统开机启动时总是出现“配置Windows请勿关机”的提示&#xff0c;没过几秒后电脑自动重启&#xff0c;每次开机都这样无法进入系统&#xff0c;此时碰到这种现象的用户就可以使用以下5种方法解决问题。方法一&#xff1a;开机按下F8&#xff0c;在出现的Windows高级启动选…...

    2022/11/19 21:17:12
  31. 准备windows请勿关闭计算机要多久,windows10系统提示正在准备windows请勿关闭计算机怎么办...

    有不少windows10系统用户反映说碰到这样一个情况&#xff0c;就是电脑提示正在准备windows请勿关闭计算机&#xff0c;碰到这样的问题该怎么解决呢&#xff0c;现在小编就给大家分享一下windows10系统提示正在准备windows请勿关闭计算机的具体第一种方法&#xff1a;1、2、依次…...

    2022/11/19 21:17:11
  32. 配置 已完成 请勿关闭计算机,win7系统关机提示“配置Windows Update已完成30%请勿关闭计算机”的解决方法...

    今天和大家分享一下win7系统重装了Win7旗舰版系统后&#xff0c;每次关机的时候桌面上都会显示一个“配置Windows Update的界面&#xff0c;提示请勿关闭计算机”&#xff0c;每次停留好几分钟才能正常关机&#xff0c;导致什么情况引起的呢&#xff1f;出现配置Windows Update…...

    2022/11/19 21:17:10
  33. 电脑桌面一直是清理请关闭计算机,windows7一直卡在清理 请勿关闭计算机-win7清理请勿关机,win7配置更新35%不动...

    只能是等着&#xff0c;别无他法。说是卡着如果你看硬盘灯应该在读写。如果从 Win 10 无法正常回滚&#xff0c;只能是考虑备份数据后重装系统了。解决来方案一&#xff1a;管理员运行cmd&#xff1a;net stop WuAuServcd %windir%ren SoftwareDistribution SDoldnet start WuA…...

    2022/11/19 21:17:09
  34. 计算机配置更新不起,电脑提示“配置Windows Update请勿关闭计算机”怎么办?

    原标题&#xff1a;电脑提示“配置Windows Update请勿关闭计算机”怎么办&#xff1f;win7系统中在开机与关闭的时候总是显示“配置windows update请勿关闭计算机”相信有不少朋友都曾遇到过一次两次还能忍但经常遇到就叫人感到心烦了遇到这种问题怎么办呢&#xff1f;一般的方…...

    2022/11/19 21:17:08
  35. 计算机正在配置无法关机,关机提示 windows7 正在配置windows 请勿关闭计算机 ,然后等了一晚上也没有关掉。现在电脑无法正常关机...

    关机提示 windows7 正在配置windows 请勿关闭计算机 &#xff0c;然后等了一晚上也没有关掉。现在电脑无法正常关机以下文字资料是由(历史新知网www.lishixinzhi.com)小编为大家搜集整理后发布的内容&#xff0c;让我们赶快一起来看一下吧&#xff01;关机提示 windows7 正在配…...

    2022/11/19 21:17:05
  36. 钉钉提示请勿通过开发者调试模式_钉钉请勿通过开发者调试模式是真的吗好不好用...

    钉钉请勿通过开发者调试模式是真的吗好不好用 更新时间:2020-04-20 22:24:19 浏览次数:729次 区域: 南阳 > 卧龙 列举网提醒您:为保障您的权益,请不要提前支付任何费用! 虚拟位置外设器!!轨迹模拟&虚拟位置外设神器 专业用于:钉钉,外勤365,红圈通,企业微信和…...

    2022/11/19 21:17:05
  37. 配置失败还原请勿关闭计算机怎么办,win7系统出现“配置windows update失败 还原更改 请勿关闭计算机”,长时间没反应,无法进入系统的解决方案...

    前几天班里有位学生电脑(windows 7系统)出问题了&#xff0c;具体表现是开机时一直停留在“配置windows update失败 还原更改 请勿关闭计算机”这个界面&#xff0c;长时间没反应&#xff0c;无法进入系统。这个问题原来帮其他同学也解决过&#xff0c;网上搜了不少资料&#x…...

    2022/11/19 21:17:04
  38. 一个电脑无法关闭计算机你应该怎么办,电脑显示“清理请勿关闭计算机”怎么办?...

    本文为你提供了3个有效解决电脑显示“清理请勿关闭计算机”问题的方法&#xff0c;并在最后教给你1种保护系统安全的好方法&#xff0c;一起来看看&#xff01;电脑出现“清理请勿关闭计算机”在Windows 7(SP1)和Windows Server 2008 R2 SP1中&#xff0c;添加了1个新功能在“磁…...

    2022/11/19 21:17:03
  39. 请勿关闭计算机还原更改要多久,电脑显示:配置windows更新失败,正在还原更改,请勿关闭计算机怎么办...

    许多用户在长期不使用电脑的时候&#xff0c;开启电脑发现电脑显示&#xff1a;配置windows更新失败&#xff0c;正在还原更改&#xff0c;请勿关闭计算机。。.这要怎么办呢&#xff1f;下面小编就带着大家一起看看吧&#xff01;如果能够正常进入系统&#xff0c;建议您暂时移…...

    2022/11/19 21:17:02
  40. 还原更改请勿关闭计算机 要多久,配置windows update失败 还原更改 请勿关闭计算机,电脑开机后一直显示以...

    配置windows update失败 还原更改 请勿关闭计算机&#xff0c;电脑开机后一直显示以以下文字资料是由(历史新知网www.lishixinzhi.com)小编为大家搜集整理后发布的内容&#xff0c;让我们赶快一起来看一下吧&#xff01;配置windows update失败 还原更改 请勿关闭计算机&#x…...

    2022/11/19 21:17:01
  41. 电脑配置中请勿关闭计算机怎么办,准备配置windows请勿关闭计算机一直显示怎么办【图解】...

    不知道大家有没有遇到过这样的一个问题&#xff0c;就是我们的win7系统在关机的时候&#xff0c;总是喜欢显示“准备配置windows&#xff0c;请勿关机”这样的一个页面&#xff0c;没有什么大碍&#xff0c;但是如果一直等着的话就要两个小时甚至更久都关不了机&#xff0c;非常…...

    2022/11/19 21:17:00
  42. 正在准备配置请勿关闭计算机,正在准备配置windows请勿关闭计算机时间长了解决教程...

    当电脑出现正在准备配置windows请勿关闭计算机时&#xff0c;一般是您正对windows进行升级&#xff0c;但是这个要是长时间没有反应&#xff0c;我们不能再傻等下去了。可能是电脑出了别的问题了&#xff0c;来看看教程的说法。正在准备配置windows请勿关闭计算机时间长了方法一…...

    2022/11/19 21:16:59
  43. 配置失败还原请勿关闭计算机,配置Windows Update失败,还原更改请勿关闭计算机...

    我们使用电脑的过程中有时会遇到这种情况&#xff0c;当我们打开电脑之后&#xff0c;发现一直停留在一个界面&#xff1a;“配置Windows Update失败&#xff0c;还原更改请勿关闭计算机”&#xff0c;等了许久还是无法进入系统。如果我们遇到此类问题应该如何解决呢&#xff0…...

    2022/11/19 21:16:58
  44. 如何在iPhone上关闭“请勿打扰”

    Apple’s “Do Not Disturb While Driving” is a potentially lifesaving iPhone feature, but it doesn’t always turn on automatically at the appropriate time. For example, you might be a passenger in a moving car, but your iPhone may think you’re the one dri…...

    2022/11/19 21:16:57