王文伟
王文伟
# List ``` val numbers = List(1, 2, 3, 4) 1::2::3::4 ``` # set `Set(1,2,3)` # Seq ``` scala> Seq(1, 1, 2) res3: Seq[Int] = List(1, 1, 2) ``` #...
# 类型和多态 ## 类型 - 参数化多态性 粗略地说,就是泛型编程 - (局部)类型推断 粗略地说,就是为什么你不需要这样写代码val i: Int = 12: Int - 存在量化 粗略地说,为一些没有名称的类型进行定义 - 视窗 我们将下周学习这些;粗略地说,就是将一种类型的值“强制转换”为另一种类型 ## 变性 Variance Scala的类型系统必须同时解释类层次和多态性。类层次结构可以表达子类关系。在混合OO和多态性时,一个核心问题是:如果T’是T一个子类,Container[T’]应该被看做是Container[T]的子类吗?变性(Variance)注解允许你表达类层次结构和多态类型之间的关系: | | 含义 |Scala 标记|...
``` [...] org.apache.maven.plugins maven-compiler-plugin 3.1 true true ${JDK1.7JAVAC} 1.7 [...] ``` mvn clean install -Dmaven.test.skip=true -Dmaven.compiler.execu table=/opt/souche/java/bin/javac -Dmaven.compiler.fork=true
# 函数 ``` scala> object plus extends Function1[Int,Int]{ | def apply(m:Int) =m+1 | } defined module plus scala> plus(0) res29: Int = 1 ``` 可以使用更直观快捷的extends (Int => Int)代替extends Function1[Int, Int]...
## 方案1 通过MyBatis配置文件创建读写分离两个DataSource,每个SqlSessionFactoryBean对象的mapperLocations属性制定两个读写数据源的配置文件。将所有读的操作配置在读文件中,所有写的操作配置在写文件中。 * 优点:实现简单 * 缺点:维护麻烦,需要对原有的xml文件进行重新修改,不支持多读,不易扩展 * 实现方式 ``` ``` ## 方案2 通过Spring AOP在业务层实现读写分离,在DAO层调用前定义切面,利用Spring的AbstractRoutingDataSource解决多数据源的问题,实现动态选择数据源 * 优点:通过注解的方法在DAO每个方法上配置数据源,原有代码改动量少,易扩展,支持多读 * 缺点:需要在DAO每个方法上配置注解,人工管理,容易出错 * 实现方式 ``` //定义枚举类型,读写 public enum DynamicDataSourceGlobal { READ, WRITE; }...
假设有如下业务:有一堆有颜色和重量的苹果,我需要通过颜色和重量取出相应苹果 定义苹果 ``` public class Apple { private int weight = 0; private String color = ""; public Apple(int weight, String color){ this.weight = weight; this.color = color; } public...
公司基础框架是通过反射来获取controller层的,会丢失aop的东西,修改框架拿到被代理的对象就行了。 ``` public static Object getTarget(Object proxy) { if (!AopUtils.isAopProxy(proxy)) { return proxy;// 不是代理对象 } if (AopUtils.isJdkDynamicProxy(proxy)) { return getJdkDynamicProxyTargetObject(proxy); } else { // cglib return getCglibProxyTargetObject(proxy); } } ```...
python 风格指南:http://zh-google-styleguide.readthedocs.io/en/latest/google-python-styleguide/contents/ python vim配置:https://github.com/google/styleguide/blob/gh-pages/google_python_style.vim shell 风格指南: http://zh-google-styleguide.readthedocs.io/en/latest/google-shell-styleguide/contents/ JSON 风格指南: https://github.com/darcyliu/google-styleguide/blob/master/JSONStyleGuide.md HTTP 接口设计指南:https://github.com/bolasblack/http-api-guide/blob/master/README.md Java编码指南:https://waylau.gitbooks.io/java-code-conventions/ 阿里巴巴版本:https://102.alibaba.com/newsInfo.htm?newsId=6 CoffeeScript 编码指南:https://github.com/elrrrrrrr/coffeescript-style-guide/blob/master/README-ZH.md 前端编码指南:http://alloyteam.github.io/CodeGuide/
在~/.ssh 添加config文件 # github Host github.com HostName github.com User xxx PreferredAuthentications publickey IdentityFile ~/.ssh/id_rsa.github github: ssh-keygen -t rsa -f ~/.ssh/id_rsa.github -C "[email protected]" gitlab: ssh-keygen -t rsa -C "[email protected]" ssh-add ~/.ssh/id_rsa.github...
使用开源项目:https://github.com/CleverTap/apns-http2 ``` @Test public void sync_push_notification() throws CertificateException, UnrecoverableKeyException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException, IOException { FileInputStream cert = new FileInputStream("/path/to/certificate.p12"); final ApnsClient client = new ApnsClientBuilder() .withProductionGateway(false) .inSynchronousMode() .withCertificate(cert) .withPassword("1") //...