2022

2022-01-13

服务器重启没多久就假死,CPU占用超高。用户量也不高呀,后来去掉日志打印,就稳定了。

2022-01-13

绿色版的xshell,提示要强制更新“要继续使用此程序,您必须应用最新的更新或使用新版本”。

后来用安装包解压,就能打开了。可能是杀毒软件又干了什么坏事。

2022-02-11

html的head中加入这个,可以指定基路径,代码里的相对路径./xxx.png也会是以为这个基路径为准。

 <base href="http://113.136.202.123:6033/epg/">

2022-02-12

Log4j 1.x 在高并发情况下出现死锁导致cpu使用率异常飙升。来自https://www.cnblogs.com/hafiz/p/6160298.html

2022-02-18

Runtime.getRuntime().addShutdownHook(thread); 可以在程序结束的时候做点事。

2022-02-19

org.apache.logging.log4j.core.tools.picocli.CommandLine

提供了命令行工具,只要定义好参数类,就可以自动从命令行读参数,接来来就自行处理逻辑。

2022-02-28

严重: Unable to process Jar entry [META-INF/versions/9/module-info.class] from Jar [jar:file:/project/api/API_ROP/WEB-INF/lib/log4j-api-2.12.4.jar!/] for annotations
org.apache.tomcat.util.bcel.classfile.ClassFormatException: Invalid byte tag in constant pool: 19

然后我就把log4j-api-2.12.4.jar中的META-INF/versions/9/module-info.class这个类删除,就好了。

2022-03-06

控制台好多这样的日志:

三月 06, 2022 6:56:58 下午 org.hibernate.engine.internal.StatisticalLoggingSessionEventListener end
INFO: Session Metrics {
3906 nanoseconds spent acquiring 1 JDBC connections;
0 nanoseconds spent releasing 0 JDBC connections;
37556 nanoseconds spent preparing 1 JDBC statements;
342516 nanoseconds spent executing 1 JDBC statements;
0 nanoseconds spent executing 0 JDBC batches;
0 nanoseconds spent performing 0 L2C puts;
0 nanoseconds spent performing 0 L2C hits;
0 nanoseconds spent performing 0 L2C misses;
13821 nanoseconds spent executing 1 flushes (flushing a total of 1 entities and 0 collections);
601 nanoseconds spent executing 1 partial-flushes (flushing a total of 0 entities and 0 collections)
}

想禁的话,找到dao.xml中的sessionFactory节点中的设为false

<prop key="hibernate.generate_statistics">false</prop>

2022-03-19

根据返回变量申明的类型自动类型转换。 public static <T extends Object> T test(String key)

 

public class Main2 {
    private static Map map = new HashMap();
    public static void main(String[] args) {
        map.put("a", 1);
        map.put("b", "abc");
        map.put("c", 6.69d);
        
        int a = test("a");
        System.out.println(a);
        
        String b = test("b");
        System.out.println(b);
        
        Double c = test("c");
        System.out.println(c);
        
        String d = getStr();
        System.out.println(d);
    }
    public static <T extends Object> T test(String key){
        return (T) map.get(key);
    }
    public static String getStr(){
        return test("b");
    }
}

2022-04-10

严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.apache.commons.logging.LogConfigurationException: User-specified log class 'org.apache.commons.logging.impl.Log4JLogger' cannot be found or is not useable.

 加这个包兼容就不报错了。

<dependency>

  <groupId>org.slf4j</groupId>
  <artifactId>jcl-over-slf4j</artifactId>
  <version>1.7.13</version>
</dependency>

2

ERROR StatusLogger Caught java.lang.AbstractMethodError setting feature http://xml.org/sax/features/external-general-entities to false on DocumentBuilderFactory org.apache.xerces.jaxp.DocumentBuilderFactoryImpl@4174c168: java.lang.AbstractMe
thodError: javax.xml.parsers.DocumentBuilderFactory.setFeature(Ljava/lang/String;Z)V
java.lang.AbstractMethodError: javax.xml.parsers.DocumentBuilderFactory.setFeature(Ljava/lang/String;Z)V
at org.apache.logging.log4j.core.config.xml.XmlConfiguration.setFeature(XmlConfiguration.java:204)
at org.apache.logging.log4j.core.config.xml.XmlConfiguration.disableDtdProcessing(XmlConfiguration.java:197)
at org.apache.logging.log4j.core.config.xml.XmlConfiguration.newDocumentBuilder(XmlConfiguration.java:186)
at org.apache.logging.log4j.core.config.xml.XmlConfiguration.<init>(XmlConfiguration.java:89)
at org.apache.logging.log4j.core.config.xml.XmlConfigurationFactory.getConfiguration(XmlConfigurationFactory.java:46)
at org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration(ConfigurationFactory.java:493)
at org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration(ConfigurationFactory.java:425)
at org.apache.logging.log4j.core.config.ConfigurationFactory.getConfiguration(ConfigurationFactory.java:294)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:647)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:668)
at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:253)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:153)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194)
at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getContext(AbstractLoggerAdapter.java:138)
at org.apache.logging.slf4j.Log4jLoggerFactory.getContext(Log4jLoggerFactory.java:45)
at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:48)
at org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:30)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:285)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:305)
at com.dr.iptv.ms.biz.common.CommonBiz.<clinit>(CommonBiz.java:40)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147)

这个错误,本身不影响启动,服务器能正常启动,功能正常。就是启动的时候打印了错误信息,但给人造成错觉。

参考这个贴子:https://blog.csdn.net/huwise/article/details/109668173

我写了一个ServletContextListener实现类

public class xxx  implements ServletContextListener{

@Override
public void contextInitialized(ServletContextEvent sce) {
// TODO Auto-generated method stub
System.setProperty("javax.xml.parsers.DocumentBuilderFactory","com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl");

}

@Override
public void contextDestroyed(ServletContextEvent sce) {
// TODO Auto-generated method stub

}

}

在web.xml里面,把它放在ContextLoaderListener之前就可以了。

<listener>
<listener-class>com.dr.iptv.xxx.sys.xxx</listener-class>
</listener>

<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

2022-05-23

用Eclipse写html的时候,有时候回车一下,就多了一个},妙名其妙。后来找到原因,是注解的代码中有半个{。代码虽然被注解了,IDE还是认为它存在(bug)

2022-05-31

服务启动时,报ERROR StatusLogger Caught java.lang.AbstractMethodError setting feature http://apache.org/xml/feature错误(但是不影响系统功能使用)

其中一个解决方式是:移除log4j-web-2.12.4.jar架包。

2022-07-24

为什么32位的电脑只支持4GB的内存?

通常32位的电脑它的寄存器是32位的。然后cpu一般是把数值型的数据读到寄存器里,比如加法add a b,就是把a值和b值读到寄存器里,然后相加。现比如代码执行跳转(goto),也是

从寄存器里去读内存的地址。内存是8位一个单元(地址)。所以32位对应的内存大小是1B*2的32次方。即4GB。(1B是因为一个内存地址对应8位。)

2022-08-13

用root启动的tomcat果然危险,特别是有jsp加成。那不要太酸爽。

2022-08-23

原来老白菜是专为windows安装设计的,如果想装linuxicon还需要点基础知识,不想windows那样傻瓜式操作。

2022-09-03

今日头条的mdl文件原来是mp4文件。

2022-09-08

java.lang.UnsupportedOperationException: clientBuilder.sslSocketFactory(SSLSocketFactory) not supported on JDK 9+

jdk升级1.8后,okhttp报错。后来我们把jdk回退到1.8.0_202就好了。最后面的202版本。

2022-10-31

把以前安装的向日葵卸载了,然后安装最新版本的向日葵软件,居然电脑不再无故死机了。棒棒。

2022-11-15

昨天晚上割接,又一个功能不生效,奇了怪了。也没看看到它报错,百思不得其解。然后就加日志打印,一直跟踪到http请求。

也没报错,然后就没发结果了。就像一个断头路。后来发现服务器上http的版本是httpclient-4.2.2.jar和httpcore-4.2.2.jar,而我本地的版本是

httpclient-4.5.5.jar和httpcore-4.4.9.jar。用本地版本替换服务器上的,居然好了。

真怪。今天,我在本地用4.2.2版本跑,启动报错:

    The import org.apache.http.client.methods.CloseableHttpResponse cannot be resolved
    The import org.apache.http.impl.client.CloseableHttpClient cannot be resolved
    The import org.apache.http.impl.client.HttpClientBuilder cannot be resolved
    CloseableHttpClient cannot be resolved to a type
    CloseableHttpResponse cannot be resolved to a type
    HttpClientBuilder cannot be resolved

2022-11-21

SpringBoot启动慢的2个原因:

原因1:

17-Nov-2022 13:38:05.927 WARNING [localhost-startStop-1] org.apache.catalina.util.SessionIdGeneratorBase.createSecureRandom Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [411,046] milliseconds.

出现SecureRandom的话,就是随机数的问题,解决办法:

在bin/catalina.sh中找到

JAVA_OPTS="$JAVA_OPTS $JSSE_OPTS"后面加上

JAVA_OPTS="$JAVA_OPTS -Djava.security.egd=file:/dev/./urandom"

参考博客:https://www.cnblogs.com/greys/p/10722950.html

原因2:

就是启动慢,主要表现在是log4j2启动慢,直接表现是java.net.InetAddress.getLocalHost()方法慢,耗时16s到30s不等

解决办法是在/etc/hosts中配置本机的ip和域名,比如你的主机号abc

那就是要配127.0.0.1 abc

参考博客:https://blog.csdn.net/weixin_39355187/article/details/113008689

2022-11-24

log4j2.xml里面加上monitorInterval参数,就可以不用重启修改log4j配置了。

<Configuration status="info" monitorInterval="5">   每5s扫描一次有没有修改。

2022-12-28

http://tools.jb51.net/password/sha1encode/

这个网页的sha1算法有问题。伤不起。

比如  发货成功  的sha1应该是10F4D8452363DA4D94B093EB2436D4F2A2C65312        http://www.metools.info/code/c22.html

而它却是:425F5DE16432C3D0948B4061C46CED0289E25C7C     http://tools.jb51.net/password/sha1encode/

不过简单的abc的话,它又正常,囧。

posted on 2022-01-02 15:15  angelshelter  阅读(419)  评论(0编辑  收藏  举报

导航