PF4J是一个Java轻量级的插件框架,可以实现动态加载,执行,卸载外部插件(支持jar
以及zip
),具体可以看官网介绍。
本文例子基于Github地址:https://github.com/pf4j/pf4j
1 | <dependency> |
得之坦然,失之淡然
PF4J是一个Java轻量级的插件框架,可以实现动态加载,执行,卸载外部插件(支持jar
以及zip
),具体可以看官网介绍。
本文例子基于Github地址:https://github.com/pf4j/pf4j
1 | <dependency> |
规约模式(Specification Pattern),简单来说就是就是约束条件,例如从数据库中获取到满足约束条件的数据(where
条件之后即为约束条件):
1 | select * from `book` where `name` like `%java%` and `price` < 50; |
如果我们要用java
实现类似约束,可能会想到:
1 | for (Book book : books) { |
摘自
Environment
注释:Properties play an important role in almost all applications, and may originate from a variety of sources: properties files, JVM system properties, system environment variables, JNDI, servlet context parameters, ad-hoc Properties objects, Maps, and so on. The role of the environment object with relation to properties is to provide the user with a convenient service interface for configuring property sources and resolving properties from them.
摘自
Environment
注释:A profile is a named, logical group of bean definitions to be registered with the container only if the given profile is active. Beans may be assigned to a profile whether defined in XML or via annotations; see the spring-beans 3.1 schema or the
@Profile
annotation for syntax details. The role of theEnvironment
object with relation to profiles is in determining which profiles (if any) are currently active, and which profiles (if any) should be active by default.
profiles
类似Maven中的profiles
,Spring允许配置多个profile
,但只加载激活的profile
,通过profiles
配置,可以实现不同环境使用不同的配置(例如不同环境使用不同的数据库配置)
Environment
表示应用当前所运行的环境。
Interface representing the environment in which the current application is running. Models two key aspects of the application
environment: profiles and properties. Methods related to property access are exposed via thePropertyResolver
superinterface.A profile is a named, logical group of bean definitions to be registered with the container only if the given profile is active. Beans may be assigned to a profile whether defined in XML or via annotations; see the spring-beans 3.1 schema or the
@Profile
annotation for syntax details. The role of theEnvironment
object with relation to profiles is in determining which profiles (if any) are currently active, and which profiles (if any) should be active by default.Properties play an important role in almost all applications, and may originate from a variety of sources: properties files, JVM system properties, system environment variables, JNDI, servlet context parameters, ad-hoc Properties objects, Maps, and so on. The role of the environment object with relation to properties is to provide the user with a convenient service interface for configuring property sources and resolving properties from them
本文主要介绍springMVC中国际化的相关配置
1 | @Bean |
SpringBean名称必须是messageSource
本文主要介绍国际化中比较重要的类Locale
,ResourceBundle
,MessageFormat
Locale表示地区,在国际化中是一个非常重要的类。
1 | import java.util.Locale; |
可以看出Locale其实是由两部分组成,即{语言}_{地区}