javaweb
javaweb copied to clipboard
http://www1350.github.io/
``` [...] 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") //...
当项目达到一定程度,配置五花八门这时候配置中心的便派上了用场。 ## 方案1 maven打包 如果只是要区分开发环境和上线环境的配置,只要打包的时候吧不同文件环境打包进来就ok了 **maven举例** ``` local true local dev dev prod production ``` ``` src/main/resources test/* production/* development/* src/main/resources/${profiles.active} ``` 或 ``` org.apache.maven.plugins maven-war-plugin 2.4 src/main/webapp/WEB-INF/web.xml /config/${package.environment}/properties WEB-INF/classes/properties...
# 基本命令 ## tail 最常用的tail -f `tail -300f shopbase.log` #倒数300行并进入实时监听文件写入模式 ## grep grep forest f.txt #文件查找 grep forest f.txt cpf.txt #多文件查找 grep 'log' /home/admin -r -n #目录下查找所有符合关键字的文件 cat f.txt |...