Author Archives: Robins

Ajax prevents page requests from reporting errors

When sending an Ajax request, if there is no corresponding file content in the requested file, or if the path is wrong, the page will report an error. Here’s a brief introduction, such as how to avoid page error reporting, or page compatibility

xhr.onreadystatechange = function() {
  
  if(xhr.readyState == 4) {
    //Verify that the file is available, using status to determine the status
    if(xhr.status >= 200 && xhr.status < 300 || xhr.status == 304) {
      box.innerHTML = xhr.responseText;
    }else {
      // Error page, server error or not found error
      console.error("Error Request")
    }
  }
}

This page will not appear the following error problem

The error will be output on the console

JSON parse error: raw timestamp (1595952000000) not allowed for

The solution is to add a local DataTime serialized configuration class, which will be transferred again when accepted

@Configuration
public class LocalDateTimeSerializerConfig {

    @Bean
    public Jackson2ObjectMapperBuilderCustomizer jackson2ObjectMapperBuilderCustomizer() {
        return builder -> {
            builder.serializerByType(LocalDateTime.class, new LocalDateTimeSerializer());
            builder.deserializerByType(LocalDateTime.class, new LocalDateTimeDeserializer());
        };
    }

    /**
     * Serialization
     */
    public static class LocalDateTimeSerializer extends JsonSerializer<LocalDateTime> {
        @Override
        public void serialize(LocalDateTime value, JsonGenerator gen, SerializerProvider serializers)
                throws IOException {
            if (value != null) {
                long timestamp = value.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
                gen.writeNumber(timestamp);
            }
        }
    }

    /**
     *Deserialization
     */
    public static class LocalDateTimeDeserializer extends JsonDeserializer<LocalDateTime> {
        @Override
        public LocalDateTime deserialize(JsonParser p, DeserializationContext deserializationContext)
                throws IOException {
            long timestamp = p.getValueAsLong();
            if (timestamp > 0) {
                return LocalDateTime.ofInstant(Instant.ofEpochMilli(timestamp), ZoneId.systemDefault());
            } else {
                return null;
            }
        }
    }
}

How to Solve can‘t connect to local mysql server through socket ‘/var/lib/mysql/mysql.sock‘

After the MySQL dataDir directory is migrated, the error prompts “can’t connect to local MySQL server through socket ‘/ var/lib/MySQL”/ mysql.sock ‘

solve:

Open my.cnf The changes are as follows:

[client]
port = 3306
socket = /new/mysql/ mysql.sock

[mysqld]

datadir=/new/mysql
socket=/new/mysql/ mysql.sock

Oracle 11g installation prompt ora-27102: out of memory

Today is March 16, 2021. When you install Oracle, you will be prompted to create memory:

Check the system memory. Free – M 128G memory only uses 1GB. This problem is caused by improper adjustment of kernel parameters. The two main parameters that lead to this problem are as follows:

kernel.shmmax and kernel.shmall

SHMMAX = physical memory (bytes)/2 – 1

Shmall = physical memory (bytes)/PageSize (getconf PageSize)

Adjust these two tests and recreate the database.

Command “/usr/bin/python -u -c “import setuptools, tokenize;__file__=‘/tmp/pip-cus9V0-build/setup.py

Command “/usr/bin/python -u -c “import setuptools, tokenize;file=’/tmp/pip-cus9V0-build/setup.py’;f=getattr(tokenize, ‘open’, open)(file);code=f.read().replace(’\r\n’, ‘\n’);f.close();exec(compile(code, file, ‘exec’))” install –record /tmp/pip-Ebvaxk-record/install-record.txt –single-version-externally-managed –compile” failed with error code 1 in /tmp/pip-cus9V0-build/

Solution:
ubuntu

apt-get install python-dev

cents

yum install python-devel

It should be the lack of Python dev dependency when running Python lzop

io.UnsupportedOperation : not writable exception resolution

Today, when doing Python language sense exercise, I reported the following exception:

is the red exception
this is the red exception io.UnsupportedOperation : not writable

Write permission is not supported. After a careful inspection, I found that I forgot to set the permissions when I opened the file for the first time, so after I added it, the program ran successfully!!!

Cmake[Warning]:Policy CMP0054 is not set

Policy CMP0054 is not set: Only interpret if() arguments as variables or keywords when unquoted

Refer to prompt cause solution

reference resources

How to use variables and avoid CMP0054 policy violations?CMP0054

Prompt reason

Note: You only get the CMP0054 warning if the context of your variable was actually evaluated again (so it’s a hint your CMake code will not work in those places).

solve

cmake_policy(SET CMP0054 NEW)

When I first learned mybatis org.apache.ibatis . binding.BindingException report errors

Error analysis: due to each Mapper.xml You need to register in the mybatis core configuration file

Solution: in mybatis- config.xml Add the following lines of code to the configuration file (note that the path must be filled in correctly, according to COM/LyP/Dao)/ UserMapper.xml (fill in the form of)

 <mappers>
        <mapper resource="com/lyp/dao/UserMapper.xml"/>
 </mappers>

Mybatis error

Mybatis error

Error starting ApplicationContext. To display the conditions report re-run your application with ‘debug’ enabled.
2021-03-16 14:44:47.948 ERROR 11288 — [ restartedMain] o.s. boot.SpringApplication : Application run failed

org.springframework.beans . factory.UnsatisfiedDependencyException : Error creating bean with name ‘helloController’: Unsatisfied dependency expressed through field ‘userService’; nested exception is org.springframework.beans . factory.UnsatisfiedDependencyException : Error creating bean with name ‘userService’: Unsatisfied dependency expressed through field ‘userMapper’; nested exception is org.springframework.beans . factory.UnsatisfiedDependencyException : Error creating bean with name ‘userMapper’ defined in file [E:\IdeaWorkspace\boot-05-web-01\target\classes\com\atguigu\boot\mapper\ UserMapper.class ]: Unsatisfied dependency expressed through bean property ‘sqlSessionFactory’; nested exception is org.springframework.beans . factory.BeanCreationException : Error creating bean with name ‘sqlSessionFactory’ defined in class path resource [org/mybatis/spring/boot/autoconfigure/Myba tisAutoConfiguration.class ]: Bean instantiation via factory method failed; nested exception is org.springframework.beans .BeanInstantiationException: Failed to instantiate [ org.apache.ibatis . session.SqlSessionFactory ]: Factory method ‘sqlSessionFactory’ threw exception; nested exception is org.springframework.core .NestedIOException: Failed to parse config resource: class path resource [mybatis/mybatis- config.xml ]; nested exception is org.apache.ibatis . builder.BuilderException : Error parsing SQL Mapper Configuration. Cause: java.io.IOException : Could not find resource org/mybatis/example/ BlogMapper.xml

https://www.bilibili.com/video/BV1Et411Y7tQ?p=174
The teacher wrote the code according to Zhou Yang

Finally, the configuration file should be left blank

The data can be obtained normally

In addition, the database has timezone problems

useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC

Uncaught Error: THREE.OBJLoader : unexpected line: “DOCTYPE HTML” [solved]

Today’s problem really makes me despair. What you netizens say is that it’s OK to put it under static, but I can’t do it here 😥
Then I found that I had a static folder under public. After testing, I found that it was really static under public….
The code can still be written as usual

summary
obj file is put under public/static
questions
but why I don’t understand?If you know, please leave a message in the comment area 😁