Alwyn's Flipped


  • 首页

  • 分类

  • 标签

  • 归档

  • 日程表

  • 关于

  • 搜索

Redis获取资源失败

发表于 2019-01-05 | | 阅读次数:
字数统计: 0 | 阅读时长 ≈ 1

Maven profile in IntellJ IDEA

发表于 2018-11-02 | 分类于 maven | | 阅读次数:
字数统计: 631 | 阅读时长 ≈ 3
IntelliJ IDEA lets you use Maven build profiles which can help you customize builds for a particular environment, for example, production or development.
阅读全文 »

java动态代理

发表于 2018-10-29 | | 阅读次数:
字数统计: 321 | 阅读时长 ≈ 1
JAVA中的JDK是基于接口的,而CGLIB是基于子类的方式来进行动态代理,实现AOP的基础。
阅读全文 »

Ubuntu设置NFS共享文件服务器

发表于 2018-10-26 | 分类于 linux , java | | 阅读次数:
字数统计: 365 | 阅读时长 ≈ 1
多个服务器共享同一个文件服务器,通过NFS网络文件系统来设置。
阅读全文 »

sftp and ftp in java

发表于 2018-10-26 | | 阅读次数:
字数统计: 1.6k | 阅读时长 ≈ 8

FTP是一种文件传输协议,一般是为了方便数据共享的。包括一个FTP服务器和多个FTP客户端。FTP客户端通过FTP协议在服务器上下载资源。而SFTP协议是在FTP的基础上对数据进行加密,使得传输的数据相对来说更安全。但是这种安全是以牺牲效率为代价的,也就是说SFTP的传输效率比FTP要低(不过现实使用当中,没有发现多大差别)。个人肤浅的认为就是:一;FTP要安装,SFTP不要安装。二;SFTP更安全,但更安全带来副作用就是的效率比FTP要低些。

阅读全文 »

hexo gitment登录问题解决

发表于 2018-10-26 | 分类于 hexo , gitment | | 阅读次数:
字数统计: 337 | 阅读时长 ≈ 1

通过自己的服务器搭建gitment评论系统

阅读全文 »

Springboot获取服务端口

发表于 2018-10-23 | 分类于 SpringBoot | | 阅读次数:
字数统计: 72 | 阅读时长 ≈ 1

Springboot项目再启动的过程中依次发布的事件为:

1
2
3
4
class org.springframework.context.event.ContextRefreshedEvent
class org.springframework.boot.web.servlet.context.**ServletWebServerInitializedEvent**
class org.springframework.boot.context.event.ApplicationStartedEvent
class org.springframework.boot.context.event.ApplicationReadyEvent

1
2
3
4
5
6
7
8
9
@Component
public class MyListener implements ApplicationListener<ServletWebServerInitializedEvent> {

@Override
public void onApplicationEvent(ServletWebServerInitializedEvent servletWebServerInitializedEvent) {
int port = servletWebServerInitializedEvent.getWebServer().getPort();
System.out.println(port);
}
}

JAVA call Shell Script

发表于 2018-10-23 | | 阅读次数:
字数统计: 239 | 阅读时长 ≈ 1
在JAVA中调用`Shell`,源于小米开源SQL优化工具[SOAR](https://github.com/XiaoMi/soar),具体工具使用方法可以直接在[GitHub](https://github.com/XiaoMi/soar)上查看。但是该工具没有界面,于是想通过前端界面发送sql到后台,由后台调用shell脚本来执行。
阅读全文 »

Redis连接池

发表于 2018-10-21 | 分类于 Redis | | 阅读次数:
字数统计: 330 | 阅读时长 ≈ 1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package com.alwyn.redis.test;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

public class RedisPoolUtils {
private static volatile JedisPool jedisPool = null;
//被volatile修饰的变量不会被本地线程缓存,对该变量的读写都是直接操作共享内存,保证变量值的“可见性”

//不能在外部创建对象
private RedisPoolUtils() {
}

public static JedisPool getInstance() { //双锁校验机制
if (jedisPool == null) {
synchronized (RedisPoolUtils.class) {
if (jedisPool == null) {
JedisPoolConfig poolConfig = new JedisPoolConfig();

//设置Jedis最大连接数
poolConfig.setMaxTotal(100);

///设置Jedis连接最大空闲数
poolConfig.setMaxIdle(10);

//设置获取Jedis连接的最大等待时间(50秒)
poolConfig.setMaxWaitMillis(50 * 1000);

//设置在获取Jedis连接时,自动检验连接是否可用
poolConfig.setTestOnBorrow(true);

//设置在将连接放回池中前,自动检验连接是否有效
poolConfig.setTestOnReturn(true);

//设置自动测试池中的空闲连接是否都是可用连接
poolConfig.setTestWhileIdle(true);

jedisPool = new JedisPool(poolConfig,"39.107.226.243", 6379);
}
}
}
return jedisPool;
}

/**
* 关闭Jedis连接
* @param jedisPool
* @param jedis
*/
public static void release(JedisPool jedisPool, Jedis jedis) {
if (null != jedis) {
jedisPool.returnResourceObject(jedis);
}
}

}

测试

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package com.alwyn.redis.test;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

public class JedisPoolDemo {
public static void main(String[] args) {
JedisPool jedisPool = RedisPoolUtils.getInstance();
Jedis jedis = null;
try
{
jedis = jedisPool.getResource();
jedis.set("k18","v183");
} catch (Exception e) {
e.printStackTrace();
}finally{
RedisPoolUtils.release(jedisPool, jedis);
}
}
}

Spring注解开发实现零配置

发表于 2018-10-21 | 分类于 SpringFramework | | 阅读次数:
字数统计: 253 | 阅读时长 ≈ 1

Spring是一个管理Bean的容器,由于Bean与Bean之间的依赖关系而引入了DI从而实现一种IOC,即控制反转,因此Spring容器也可以被称作IOC容器(ApplicationContext)。

阅读全文 »
12
alwyn

alwyn

14 日志
12 分类
15 标签
GitHub E-Mail
Links
  • baidu
  • zhihu
© 2016 — 2019 alwyn | Site words total count: 5.1k
0%