Category Archives: JAVA

[Solved] Failed to load class org.slf4j.impl.StaticLoggerBinder

The version of slf4j-log4j12 I used is 1.7.30, and I encountered an error when using Failed to load class org.slf4j.impl.StaticLoggerBinder:
Failed to load class org.slf4j.impl.StaticLoggerBinder
This warning message is reported when the org.slf4j.impl.StaticLoggerBinder class could not be loaded into memory. This happens when no appropriate SLF4J binding could be found on the class path. Placing one (and only one) of slf4j-nop.jar slf4j-simple.jar, slf4j-log4j12.jar, slf4j-jdk14.jar or logback-classic.jar on the class path should solve the problem.
According to the original statement, any one (and only one) of slf4j-nop.jar slf4j-simple.jar, slf4j-log4j12.jar, slf4j-jdk14.jar or logback-classic.jar can be in the class path, But this is the situation when the error is reported. My solution is to add slf4j-simple.jar 1.7.30 to the Maven dependency, and this error no longer appears.

[Solved] Hadoop failed on connection exception: java.net.ConnectException: Connection refused

First use the following command to check whether the port number is enabled

sudo netstat -ntlp

If you don’t find the port number you want to connect to, go to core-site.xml to see if you have this port number.

I don’t deserve 8020. I haven’t been connected with 8020 for a long time.

<property>
        <name>fs.defaultFS</name>
        <value>hdfs://hadoop131:9820</value>
</property>

You can change the port number of the connection to your own

Springboot Project Error: Failed to execute goal org.apache.maven.plugins

Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.1.0:resources (default-resources) on project heima-leadnews-user: Error loading property file ‘D:\Develop\springboot_ project\heima-leadnews\heima-leadnews-user\maven_ test.properties’

When installing the springboot project, the above errors were compiled. Baidu’s reason is that the Maven version, JDK version and packaging program are occupied. My reason is that the parent project of the project has the following profiles:

<!--<profiles>
        <profile>
            <id>dev</id>
            <build>
                <filters>
                    <filter>maven_dev.properties</filter>
                </filters>
            </build>
        </profile>
        <profile>
            <id>test</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <build>
                <filters>
                    <filter>maven_test.properties</filter>
                </filters>
            </build>
        </profile>
        <profile>
            <id>prod</id>
            <build>
                <filters>
                    <filter>maven_prod.properties</filter>
                </filters>
            </build>
        </profile>
    </profiles>-->

Because my child project inherits the parent project, but there is no corresponding directory under the child project, the above code in the parent project is cancelled (the specific reason is unknown, learning from the teacher), recompiled and packaged successfully

Gitee Idea Push Error: Invocation failed Server returned invalid Response. java.lang.RuntimeException

Invocation failed Server returned invalid Response. java.lang.RuntimeException: Invocation failed Server returned invalid Response. at org.jetbrains.git4idea.GitAppUtil.sendXmlRequest(GitAppUtil.java:22) at org.jetbrains.git4idea.http.GitAskPassApp.main(GitAskPassApp.java:56) Caused by: java.io.IOException: Server returned invalid Response. at org.apache.xmlrpc.LiteXmlRpcTransport.sendRequest(LiteXmlRpcTransport.java:242) at org.apache.xmlrpc.LiteXmlRpcTransport.sendXmlRpc(LiteXmlRpcTransport.java:90) at org.apache.xmlrpc.XmlRpcClientWorker.execute(XmlRpcClientWorker.java:72) at org.apache.xmlrpc.XmlRpcClient.execute(XmlRpcClient.java:194) at org.apache.xmlrpc.XmlRpcClient.execute(XmlRpcClient.java:185) at org.apache.xmlrpc.XmlRpcClient.execute(XmlRpcClient.java:178) at org.jetbrains.git4idea.GitAppUtil.sendXmlRequest(GitAppUtil.java:19) … 1 more unable to read askpass response from ‘C:\Users\WD\AppData\Local\JetBrains\IntelliJIdea2021.1\tmp\intellij-git-askpass-local.sh’ bash: /dev/tty: No such device or address failed to execute prompt script (exit code 1) could not read Username for ‘https://gitee.com’: No such file or directory

 

Solution:
Click File -> Settings -> Version Control -> Gitee,
and refresh your Gitee account.

[Solved] Failed to configure a DataSource: ‘url‘ attribute is not specified…bug

Question page

Error message in log
no mybatis mapper was found in ‘[com. Ego]’ package. Please check your
configuration. Will not attempt to authenticate using SASL (unknown error)

Console output

Solution 1

Solution 1. I read many blogs, most of which are this solution. But it didn’t solve my problem

Solution 2

1. Because the versions of spring web and spring webmvc in POM are inconsistent, unify the dependent versions
2. If there are no database related things configured, comment out the POM dependencies of mybatis and MySQL first

I cited the problem caused by mapper’s Maven dependency in the consumermodel. Just delete it.

[Solved] MultipartException: Failed to parse multipart servlet request; nested exception is java.lang.Runtime

1. Error log

org.springframework.web.multipart.MultipartException: Failed to parse multipart servlet request; nested exception is java.lang.RuntimeException: java.nio.file.NoSuchFileException: /tmp/undertow.8081.6091954911906268442/undertow2435234810596519507upload
        at org.springframework.web.multipart.support.StandardMultipartHttpServletRequest.handleParseFailure(StandardMultipartHttpServletRequest.java:124)
        at org.springframework.web.multipart.support.StandardMultipartHttpServletRequest.parseRequest(StandardMultipartHttpServletRequest.java:115)
        at org.springframework.web.multipart.support.StandardMultipartHttpServletRequest.<init>(StandardMultipartHttpServletRequest.java:88)
        at org.springframework.web.multipart.support.StandardServletMultipartResolver.resolveMultipart(StandardServletMultipartResolver.java:87)
        at org.springframework.web.servlet.DispatcherServlet.checkMultipart(DispatcherServlet.java:1178)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1012)
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
        at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)

2. Cause of problem

After consulting the blog, I know the cause of the problem:
in Linux system, when the spring boot application is started with Java jar command, a Tomcat (or undertow) temporary directory will be generated in the/tmp directory of the operating system. The uploaded files must be converted into temporary files and saved under this folder. Because the files in the temporary/tmp directory are not used for a long time (10 days), the system executes the TMP directory cleaning service (systemd-tmpfiles-clean. Service), resulting in the cleaning of/TMP/undertow… 8090 files. However, when uploading, the undertow server needs to create/TMP/undertow… 8090/undertow… Upload temporary files, However, when calling files. CreateFile (…), you will find that the parent directory cannot be found, which leads to the above error.

3. Solution

1) Restart
cannot be done once and for all
2) the directory specified by the configuration file
needs to be manually created on the server
MKDIR – P/data/tmp

spring:
  servlet:
      multipart:
          location: /data/tmp

3) Add startup parameter – Java.TMP.Dir =/path/to/application/temp/

[Solved] Redis Error: Unexpected exception while processing command

1. Background

Redis has been running for a long time, and an error is reported one day as follows:

2. Phenomenon

org.redisson.client.RedisException: Unexpected exception while processing command
at org.redisson.command.CommandAsyncService.convertException(CommandAsyncService.java:338)
at org.redisson.command.CommandAsyncService.get(CommandAsyncService.java:140)
at org.redisson.RedissonObject.get(RedissonObject.java:90)
at org.redisson.RedissonBucket.set(RedissonBucket.java:131)

3. Solution

Restart the Java application!

What exactly caused it,

You can only guess the link pool of the redis client. Due to network and other reasons, the redis client has not responded for a long time and collapsed!

perfect

[Solved] Mybatis-Plus Error: Invalid bound statement (not found)

Mybatis plus reports an error: invalid bound statement (not found)

After integrating mybatis plus in the spring boot project, it is found that the user-defined query method will report an error: “invalid bound statement (not found): * * *.” your method “, which means that your user-defined method cannot be found in the XML file. Various methods are tried and the problem is finally solved. This problem exists in the following situations:

1. Mapper file and XML file cannot correspond

1. Check whether mapper file and XML file names are consistent

UserMapper and UserMapper.xml

2. Check whether the attribute configuration of namespace in the XML file corresponds to the corresponding mapper file

<mapper namespace="com.*.*.mapper.UserMapper">

3. Check whether the method binding ID in the XML file is consistent

Mapper:
    List<User> getUserList();
xml:
    <select id="getUserList" resultType="com.*.*.entity.User">
        SELECT * FROM user
    </select>

2. The XML file is placed in the resources directory at different levels and is not packaged into the target

By default, all will be packaged. Check whether the property of not packaging is configured in the POM file, and modify it

Note: this configuration is to package the resources directory and check the differences

	<build>
        <!-- Pack the files in the resources directory -->
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>**/*.*</include>
                </includes>
            </resource>
        </resources>
     </build>

(focus on configuration, which is also my problem) third, the XML file is placed in the resources directory at different levels and has been packaged into the target, but the corresponding method cannot be found

It is thought that after packaging, you can match according to the name. Finally, it is found that even if the XML file is packaged, it still belongs to a different level from mapper, so check whether the mybatis plus configuration matching the location of the XML file is missing

mybatis-plus.mapper-locations = classpath:mapping/*.xml
# The "mapping" in this configuration corresponds to the name of the directory where your xml is located

Consumer service instance error: HTTP get http://xxx/actuator/health: 503 output: {“status”: “out_of_service”

Phenomenon

Some back-end services register with consumer and report an error HTTP get http://xxx/actuator/health: 503 output: {"status": "out_of_service", but other services can be registered normally. Find a way to print thin error messages on the Internet

Print detailed error information

Configure in the error reporting module: application.YML or bootstrap.YML as follows:

management:
  endpoint:
    health:
      show-details: always  
  endpoints:
    web:
      exposure:
        include: '*'    

Or add the following configuration in application.Properties :

management.endpoint.health.show-details=always
management.endpoints.web.exposure.include=*

Finally, after printing the detailed error information, I found that it was the ES cluster. I thought it was the problem of the consumer configuration that led to the wrong direction during troubleshooting.

How to Solve Docker Portainer Connect Error

Container startup

[root@shusheng run]# docker run -d -p 9000:9000 --restart=always -v /var/run/docker.sock:/var/run/docker.sock --name prtainer-test portainer/portainer

Portal interface access

Connect error resolution

Many Google articles talk about permission, but I use root to start it
until later

[root@shusheng run]# setenforce 0

Successfully solved