V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  git00ll  ›  全部回复第 12 页 / 共 12 页
回复总数  240
1 ... 3  4  5  6  7  8  9  10  11  12  
2021-07-31 21:45:40 +08:00
回复了 git00ll 创建的主题 问与答 poi 读取 excel 内存溢出
512m 堆内存是比文件解压后大的,但是其中有一个数组拷贝操作,导致同时会存在两个在内存里,就不够了。
所以内存要比文件解压大两倍。
2021-07-31 21:40:19 +08:00
回复了 git00ll 创建的主题 问与答 poi 读取 excel 内存溢出
首先 xlsx 文件本身是一个压缩包,即使是 event 模式,poi 也需要将压缩包内的文件全部加载在内存里,真实使用时再根据流式方式边解析边向外输出。
也就是说最低需要 xlsx 解压后的文件大小的内存才可以进行解析。
2021-07-26 18:18:49 +08:00
回复了 git00ll 创建的主题 MySQL 下面两种写法 not exist , 和 left join 哪个效率更优点
看了一下书,这两种写法是会被优化成同样的执行计划的,并且第二种写法的可读性更高一点,所以我选择第二种了
2021-07-21 15:16:27 +08:00
回复了 git00ll 创建的主题 问与答 idea 如何自定义点号 后面的提示
@AoEiuV020 你好,尝试过这个。这个是指在直接写 ‘for’,自动根据模板补全,不是在一个变量后面输入 ‘点号’ 弹出提示再补全
使用 jd 反编译出来的代码 return 上面一行,是不符合 java 语法的
todo 补充这里的注释
2021-02-09 16:43:48 +08:00
回复了 git00ll 创建的主题 Java 各位彦祖们,关于 spring 和 springmvc 不知道这样理解对不对
@huifer
以下代码来自于
org.springframework.web.servlet.FrameworkServlet#initWebApplicationContext
DispatcherServlet 继承此类。

下面是他初始化容器的地方,方法的第三行有一个 if 判断,他判断如果 webApplicationContext 不为空,就直接使用。如果为空会在下面创建一个。
那什么情况下非空呢?据我观察现在使用 springboot 启动时,就是非空的,而以前使用 xml 文件的方式就是空的。所以我认为,使用旧的方式,会产生两个容器,springmvc 容器和 spring 容器,他们是父子关系。而使用 springboot 的方式,是共享同一个容器。


protected WebApplicationContext initWebApplicationContext() {
WebApplicationContext rootContext =
WebApplicationContextUtils.getWebApplicationContext(getServletContext());
WebApplicationContext wac = null;
if (this.webApplicationContext != null) {
// A context instance was injected at construction time -> use it
wac = this.webApplicationContext;
if (wac instanceof ConfigurableWebApplicationContext) {
ConfigurableWebApplicationContext cwac = (ConfigurableWebApplicationContext) wac;
if (!cwac.isActive()) {
// The context has not yet been refreshed -> provide services such as
// setting the parent context, setting the application context id, etc
if (cwac.getParent() == null) {
// The context instance was injected without an explicit parent -> set
// the root application context (if any; may be null) as the parent
cwac.setParent(rootContext);
}
configureAndRefreshWebApplicationContext(cwac);
}
}
}
if (wac == null) {
// No context instance was injected at construction time -> see if one
// has been registered in the servlet context. If one exists, it is assumed
// that the parent context (if any) has already been set and that the
// user has performed any initialization such as setting the context id
wac = findWebApplicationContext();
}
if (wac == null) {
// No context instance is defined for this servlet -> create a local one
wac = createWebApplicationContext(rootContext);
}

if (!this.refreshEventReceived) {
// Either the context is not a ConfigurableApplicationContext with refresh
// support or the context injected at construction time had already been
// refreshed -> trigger initial onRefresh manually here.
onRefresh(wac);
}

if (this.publishContext) {
// Publish the context as a servlet context attribute.
String attrName = getServletContextAttributeName();
getServletContext().setAttribute(attrName, wac);
if (this.logger.isDebugEnabled()) {
this.logger.debug("Published WebApplicationContext of servlet '" + getServletName() +
"' as ServletContext attribute with name [" + attrName + "]");
}
}

return wac;
}
2021-02-05 12:41:00 +08:00
回复了 yayiji 创建的主题 问与答 ~和` 这两个符号一般什么用途?
git rebase HEAD~10
2021-01-15 17:36:47 +08:00
回复了 git00ll 创建的主题 MySQL mysql 一次更新大量数据,速度慢, cpu 占用高,有啥优化思路吗
@love
目前我们的做法是
update table set status = 1 where order_id = "xxxxx" and status = 2 limit 1000
然后定时执行,问题是,如果定时频率快了 cpu 扛不住,定时频率慢了,速度太慢,60w 要更新好几十分钟
2021-01-15 17:34:23 +08:00
回复了 git00ll 创建的主题 MySQL mysql 一次更新大量数据,速度慢, cpu 占用高,有啥优化思路吗
@owenliang 尝试过这样操作,其实效果也不好
下面是想要把 status 为 2 的改为 1

先选择一批数据
select id from table where order_id = "xxxxx" and status = 2 limit 1000
再更新这一批数据
update table set status = 1 where id in (上面 select 到的数据)

放在循环里更新,同样导致数据库压力
2020-10-26 16:19:29 +08:00
回复了 jamfer 创建的主题 推广 回馈 V2,送一把樱桃红轴的 71 键双模机械键盘
万一呢
2020-10-15 19:47:10 +08:00
回复了 huskar 创建的主题 健康 想看看有多少成功拔掉拔阻生智齿的?
三颗水平阻生 + 1 颗正常点的智齿。拔完很舒服,再也不用担心了
2020-09-30 18:28:29 +08:00
回复了 1oNflow 创建的主题 Java 普通新人后端有没有必要学习 Spring 源码?
普通新人后端有没有必要学习 Spring 源码?
-----------------------------------------------------
新人没必要,毕竟把 spring 全家桶的用法学会也要很长时间,
一两年后肯定是要看的,不看 spring 也要看其他的框架的,目的是提高读源码能力。
2020-09-30 12:46:39 +08:00
回复了 pythonee 创建的主题 程序员 第一次接触会觉得比较有意思的编程技术
NIO
2020-09-15 20:17:02 +08:00
回复了 git00ll 创建的主题 Java 为什么同步代码块升级到轻量级锁,而不是偏向锁了呢
自问自答一下,是因为 jvm 在加载过程中会暂时禁用偏向锁,所以此处只有轻量级锁。
可以在调用 test 方法之前,先休眠 5 秒,这样等 jvm 完全加载完成后,偏向锁才能生效,就能看到效果了。
2020-09-15 11:07:15 +08:00
回复了 jiobanma 创建的主题 Java 关于 springboot+mybatis 的事务管理问题
两个 service 的方法上都加上事务注解,默认是 REQUIRED,调用的第二个 service 会共享第一个 service 的事务,即使用同一条 jdbc 连接。
2020-09-07 13:18:38 +08:00
回复了 lihongming 创建的主题 程序员 脑子突然不好使了,请各位大佬帮我想想这个算法
楼主这题哪里做的,能发下链接吗
2020-08-25 17:22:29 +08:00
回复了 stephCurry 创建的主题 Java Logback 添加 error 级别 Appender 导致 info 级别的 Appender 无法输出
你配置了三个同名的[ur.company] logger,日志级别是后面的覆盖前面的,所以此日志的级别是 error 。
此 logger 配置了三个 appender-ref,是可以叠加的,所以 error 日志会输出三份到三个文件里。
所以应该不是不输出日志了,而是只输出 error 日志,楼主可以测一下
2019-10-22 11:40:51 +08:00
回复了 stephCurry 创建的主题 Java SLF4J 冲突, 如何指定其中一个为实现类
#### 将你想使用的实现类配置在第一个,下面 slf4j-simple 配置都在 logback-classic 前面,使用的就是 slf4j-simple

```

dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.28'
compile group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.28'
compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'
}



public static void main(String[] args) throws IOException {
Logger log = LoggerFactory.getLogger(Test.class);
log.info("info");
}

```
1 ... 3  4  5  6  7  8  9  10  11  12  
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2580 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 30ms · UTC 07:25 · PVG 15:25 · LAX 00:25 · JFK 03:25
Developed with CodeLauncher
♥ Do have faith in what you're doing.