杂货店

得之坦然,失之淡然


  • 首页

  • 标签

  • 分类

  • 归档

  • 追番

  • 站点地图

Spring中的Profiles

发表于 2019-05-20 | 分类于 Learning
本文字数: 850 | 阅读时长 ≈ 4 分钟

摘自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 the Environment 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配置,可以实现不同环境使用不同的配置(例如不同环境使用不同的数据库配置)

阅读全文 »

Spring中的Environment

发表于 2019-05-19 | 分类于 Learning
本文字数: 1.9k | 阅读时长 ≈ 9 分钟

Environment

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 the PropertyResolver 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 the Environment 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

阅读全文 »

Spring中的PropertyResolver

发表于 2019-05-19 | 分类于 Learning
本文字数: 1.8k | 阅读时长 ≈ 9 分钟

PropertyResolver在Spring中的作用是负责属性解析,例如在XML中替换占位符(${})属性,@Value注解等

阅读全文 »

一致性哈希(Consistent Hashing)

发表于 2019-04-29 | 分类于 Learning
本文字数: 1.7k | 阅读时长 ≈ 7 分钟

一致性Hash算法

需求

在使用n台缓存服务器时,一种常见的负载均衡的做法是:对资源o的请求做hash(o) mod n,来决定映射的到的服务器。当需要增加或减少缓存服务器时,最糟糕的情况是,因为所有hash(o) mod n值被改变,导致所有缓存失效。

一致性哈希要求在服务器数量变化时,也尽量使同一个资源的请求,落在同一台服务器上。

阅读全文 »

学习SpringMVC国际化(二)

发表于 2019-03-08 | 分类于 Learning
本文字数: 1k | 阅读时长 ≈ 4 分钟

本文主要介绍springMVC中国际化的相关配置

MessageSource

示例:

1
2
3
4
5
6
7
8
@Bean
public ReloadableResourceBundleMessageSource messageSource() {
ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
messageSource.setBasenames("classpath:i18n/server");
messageSource.setDefaultEncoding("UTF-8");
messageSource.setFallbackToSystemLocale(false);
return messageSource;
}

SpringBean名称必须是messageSource

阅读全文 »

Java国际化简单介绍

发表于 2019-03-06 | 分类于 Learning
本文字数: 1.3k | 阅读时长 ≈ 6 分钟

本文主要介绍国际化中比较重要的类Locale,ResourceBundle,MessageFormat

java.util.Locale

Locale表示地区,在国际化中是一个非常重要的类。

基本方法

1
2
3
4
5
6
7
8
9
10
11
12
13
14
import java.util.Locale;

public class LocaleTest {

public static void main(String[] args) {
Locale locale = Locale.getDefault();
System.out.println(locale); // zh_CN
System.out.println(locale.getCountry()); // CN
System.out.println(locale.getLanguage()); // zh
System.out.println(locale.getDisplayCountry()); // 中国
System.out.println(locale.getDisplayLanguage()); // 中文
}

}

可以看出Locale其实是由两部分组成,即{语言}_{地区}

阅读全文 »

学习SpringMVC国际化(一)

发表于 2019-03-03 | 分类于 Learning
本文字数: 1.2k | 阅读时长 ≈ 6 分钟

本文主要介绍如何使用springMVC实现国际化,项目使用jdk8+springMVC4.2.8+Velocity,全注解配置

阅读全文 »

MacOS下以tar.gz方式安装MySQL5.7

发表于 2019-02-10 | 分类于 Software
本文字数: 426 | 阅读时长 ≈ 2 分钟

下载MySql5.7

官网下载地址:点击这里

解压安装

解压并移动到指定目录

1
2
3
4
# 解压
tar zxvf mysql-5.7.25-macos10.14-x86_64.tar.gz
# 移动
sudo mv mysql-5.7.25-macos10.14-x86_64 /usr/local/mysql
阅读全文 »

第一篇做测试

发表于 2019-01-09 | 分类于 Misc
本文字数: 60 | 阅读时长 ≈ 1 分钟

第一篇文章

小标题1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
package xyz.iyichen.simple.test;

import java.net.URLEncoder;

public class Test2 {

public static void main(String[] args) throws Exception {
String nickname = '\u200e' + "User_199";
System.out.println(nickname);

System.out.println(URLEncoder.encode(nickname, "UTF-8"));
}

}
阅读全文 »
123
蛋筒冰淇淋

蛋筒冰淇淋

得之坦然,失之淡然

29 日志
6 分类
44 标签
GitHub E-Mail
Links
  • Jenkov
  • DZone
0%
© 2019 — 2021 Yichen
由 Hexo 强力驱动
|
主题 — NexT.Gemini v5.1.4