T getObject()// Return an instance (possibly shared or independent) of the object managed by this factory. Class<?> getObjectType() // Return the type of object that this FactoryBean creates, or null if not known in advance. booleanisSingleton()// Is the object managed by this factory a singleton? That is, will getObject() always return the same object (a reference that can be cached)?
Indicates that an annotated class is a “component”. Such classes are considered as candidates for auto-detection when using annotation-based configuration and classpath scanning. Other class-level annotations may be considered as identifying a component as well, typically a special kind of component: e.g. the @Repository annotation or AspectJ’s @Aspect annotation.
Configures component scanning directives for use with @Configuration classes. Provides support parallel with Spring XML’s <context:component-scan> element. Either basePackageClasses() or basePackages() (or its alias value()) may be specified to define specific packages to scan. If specific packages are not defined, scanning will occur from the package of the class that declares this annotation. Note that the <context:component-scan> element has an annotation-config attribute; however, this annotation does not. This is because in almost all cases when using @ComponentScan, default annotation config processing (e.g. processing @Autowired and friends) is assumed. Furthermore, when using AnnotationConfigApplicationContext, annotation config processors are always registered, meaning that any attempt to disable them at the @ComponentScan level would be ignored. See @Configuration‘s Javadoc for usage examples.
Annotation support for the Application Context, including JSR-250 “common” annotations, component-scanning, and Java-based metadata for creating Spring-managed objects.
XmlWebApplicationContext 从 Web 应用下的一个或多个 XML 配置文件中加载上下文定义,是 Web 应用程序使用的默认上下文类,因此不必在 web.xml 文件中显式指定这个上下文类。以下代码描述了 web.xml 中指向将由 ContextLoaderListener 监听器类载入的外部 XML 上下文文件的元素:
archetype:generate creates a Maven project from an archetype: asks the user to choose an archetype from the archetype catalog, and retrieves it from the remote repository. Once retrieved, it is processed to create a working Maven project.
archetype:create-from-project creates an archetype from an existing project.(注意如果需要包含 yml 配置文件,需要加上参数 -Darchetype.filteredExtentions=yml)
archetype:crawl search a repository for archetypes and updates a catalog.
server backend1.example.com; server backend2.example.com; server backend3.example.com down; server backend4.example.com; }
ip_hash 指令指定集群使用基于客户端 IP 地址的负载均衡方法。 客户端 IPv4 地址的前三个八位字节或整个 IPv6 地址用作哈希键。 该方法确保来自同一客户端的请求将始终传递到同一台服务器,除非此服务器不可用,客户端请求则将被转发到另一台服务器(多数情况下,始终是同一台服务器)。 如果其中一台服务器需要临时删除,则应使用 down 参数标记,以便保留当前客户端 IP 地址的哈希值。
一致性 hash
使用 Nginx hash 指令,常用的例如基于来源 IP 进行哈希,配置如下:
1 2 3 4 5 6
upstream backend { hash $remote_addr consistent;
server backend1.example.com; server backend2.example.com; }
Index Upstream Name Status Rise counts Fall counts Check type Check port 0 backend1 127.0.0.1:8080 up 4741 0 http 0 1 backend1 127.0.0.1:8081 down 0 2340 http 0
常用变量
$upstream_addr
该模块中很常用的一个变量,用于标识集群中服务器的 IP 和端口。一般会加入到 Nginx 日志、同时脱敏后加入到响应头中,用于排查问题来源:
Here is a handy table that shows you how the request will be received by your WebApp, depending on how you write the location and proxy_pass declarations. Assume all requests go to http://localhost:8080:
In other words: You usually always want a trailing slash, never want to mix with and without trailing slash, and only want without trailing slash when you want to concatenate a certain path component together (which I guess is quite rarely the case).
BOM stands for Bill Of Materials. A BOM is a special kind of POM that is used to control the versions of a project’s dependencies and provide a central place to define and update those versions.
BOM provides the flexibility to add a dependency to our module without worrying about the version that we should depend on.