Author Archives: Robins

[Solved] Tesseract ocr error: JFIF APP0 must be first marker after SOI

1. Reason

This error occurs because the image format is incomplete or the image format stored in the interface conflicts with the internal encoding.

2. Solve

Convert it to png and then call Tesseract

I packaged a tool

 // Convert the image to png format 
    public  static String convertPng(String url) {
        String tarFilePath = url.substring( 0 , url.lastIndexOf( " . " )) + " .png " ;
         try {
            BufferedImage bufferedImage = ImageIO.read( new File(url));
            BufferedImage newBufferedImage = new BufferedImage(bufferedImage.getWidth(), bufferedImage.getHeight(), BufferedImage.TYPE_INT_RGB);
            newBufferedImage.createGraphics().drawImage(bufferedImage, 0 , 0 , Color.white, null );
            ImageIO.write(newBufferedImage, " png " , new File(tarFilePath));
        } catch (IOException e) {
            return  "" ;
        }
        return tarFilePath;
    }

You cannot directly change the suffix, you need to use ImageIO to convert it, remember

[Solved] Redisson distributed lock error: attempt to unlock lock, not locked by current thread by node id

java.lang.IllegalMonitorStateException: attempt to unlock lock, not locked by current thread by node id: 193fa0a4-1df0-445f-8737-18b7bb464f64 thread-id: 80

When the Redission distributed lock performs the unlock operation, there is an abnormal source code as follows:

public void unlock() {
        try {
            this.get(this.unlockAsync(Thread.currentThread().getId()));
        } catch (RedisException var2) {
            if (var2.getCause() instanceof IllegalMonitorStateException) {
                throw (IllegalMonitorStateException)var2.getCause();
            } else {
                throw var2;
            }
        }
    }
public RFuture<Void> unlockAsync(long threadId) {
        RFuture<Boolean> future = this.unlockInnerAsync(threadId);
        CompletionStage<Void> f = future.handle((opStatus, e) -> {
            this.cancelExpirationRenewal(threadId);
            if (e != null) {
                throw new CompletionException(e);
            } else if (opStatus == null) {
                IllegalMonitorStateException cause = new IllegalMonitorStateException("attempt to unlock lock, not locked by current thread by node id: " + this.id + " thread-id: " + threadId);
                throw new CompletionException(cause);
            } else {
                return null;
            }
        });
        return new CompletableFutureWrapper(f);
    }

Why is this happening, because when the lock operation is performed, a time is set

1. After you complete the lock, when the execution time of the business code in it is greater than the lock time, and unlock it, the exception will be thrown

2. The problem of multi-thread competition. When the first thread completes the lock, it is not unlocked at this time. In this way, the second thread tries to acquire the lock and perform the lock operation, and this exception will be thrown.

Solution:

Before locking or unlocking, it is enough to judge the legality of the state, instead of directly performing the locking and unlocking operation.

[Solved] No validator could be found for constraint ‘javax.validation.constraints.NotBlank’ validating type ‘java.lang.String’

1. The error is as follows:

javax.validation.UnexpectedTypeException: HV000030: No validator could be found for constraint ' javax.validation.constraints.NotBlank ' validating type ' java.lang.String ' . Check configuration for  ' orderTime ' 
    at org.hibernate.validator. internal .engine .constraintvalidation.ConstraintTree.throwExceptionForNullValidator(ConstraintTree.java: 227 ) ~ [ hibernate - validator - 5.4.1.Final.jar : 5.4.1.Final ]
    at org.hibernate.validator.internal .engine.constraintvalidation.ConstraintTree.getConstraintValidatorNoUnwrapping (ConstraintTree.java:308 ) ~ [ hibernate - validator - 5.4.1.Final.jar : 5.4.1.Final ]
    at org.hibernate.validator.internal .engine.constraintvalidation.ConstraintTree.getConstraintValidatorInstanceForAutomaticUnwrapping (ConstraintTree.java:242 ) ~ [ hibernate - validator - 5.4.1.Final.jar : 5.4.1.Final ]
    at org.hibernate.validator.internal .engine.constraintvalidation.ConstraintTree.getInitializedConstraintValidator (ConstraintTree.java:163 ) ~ [ hibernate - validator - 5.4.1.Final.jar : 5.4.1.Final ]
    at org.hibernate.validator.internal .engine.constraintvalidation.ConstraintTree.validateConstraints (ConstraintTree.java: 116 ) ~ [ hibernate - validator - 5.4.1.Final.jar : 5.4.1.Final ]
    at org.hibernate.validator.internal .engine.constraintvalidation.ConstraintTree.validateConstraints (ConstraintTree.java:87 ) ~ [ hibernate - validator - 5.4.1.Final.jar : 5.4.1.Final ]
    at org.hibernate.validator.internal .metadata.core.MetaConstraint.validateConstraint(MetaConstraint.java: 73 ) ~ [ hibernate - validator - 5.4.1.Final.jar : 5.4.1.Final ]
    at org.hibernate.validator.internal .engine.ValidatorImpl.validateMetaConstraint (ValidatorImpl.java:616 ) ~ [ hibernate - validator - 5.4.1.Final.jar : 5.4.1.Final ]
    at org.hibernate.validator.internal .engine.ValidatorImpl.validateConstraint (ValidatorImpl.java:581 ) ~ [ hibernate - validator - 5.4.1.Final.jar : 5.4.1.Final ]
    at org.hibernate.validator.internal .engine.ValidatorImpl.validateConstraintsForSingleDefaultGroupElement (ValidatorImpl.java:527 ) ~ [ hibernate - validator - 5.4.1.Final.jar : 5.4.1.Final ]
    at org.hibernate.validator.internal .engine.ValidatorImpl.validateConstraintsForDefaultGroup (ValidatorImpl.java:495 ) ~ [ hibernate - validator - 5.4.1.Final.jar : 5.4.1.Final ]
    at org.hibernate.validator.internal .engine.ValidatorImpl.validateConstraintsForCurrentGroup (ValidatorImpl.java:460 ) ~ [ hibernate - validator - 5.4.1.Final.jar : 5.4.1.Final ]
    at org.hibernate.validator.internal .engine.ValidatorImpl.validateInContext (ValidatorImpl.java:410 ) ~ [ hibernate - validator - 5.4.1.Final.jar : 5.4.1.Final ]
    at org.hibernate.validator.internal .engine.ValidatorImpl.validate (ValidatorImpl.java:207 ) ~ [ hibernate - validator - 5.4.1.Final.jar : 5.4.1.Final ]at org.springframework.validation.beanvalidation.SpringValidatorAdapter.validate 
    (SpringValidatorAdapter.java:109 ) ~ [spring- context - 5.3.22.jar : 5.3.22 ]
    at org.springframework.boot.autoconfigure.validation.ValidatorAdapter.validate(ValidatorAdapter.java:66 ) ~ [ spring - boot - autoconfigure - 2.7.2.jar : 2.7.2 ]
    at org.springframework.validation.DataBinder.validate(DataBinder.java:933 ) ~ [spring - context - 5.3.22.jar : 5.3.22 ]
    at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodArgumentResolver.validateIfApplicable(AbstractMessageConverterMethodArgumentResolver.java:250 ) ~ [spring - webmvc - 5.3.22.jar : 5.3.22 ]
    at org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.resolveArgument(RequestResponseBodyMethodProcessor.java:139 ) ~ [ spring- webmvc - 5.3.22.jar : 5.3.22 ]
    at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:122 ) ~ [spring - web - 5.3.22.jar : 5.3.22 ]at org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues 
    (InvocableHandlerMethod.java:179 ) ~ [spring- web - 5.3.22.jar : 5.3.22 ]at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest 
    (InvocableHandlerMethod.java:146 ) ~ [spring- web - 5.3.22.jar : 5.3.22 ]at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle 
    (ServletInvocableHandlerMethod.java:117 ) ~ [spring- webmvc - 5.3.22.jar : 5.3.22 ]
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895 ) ~ [ spring- webmvc - 5.3.22.jar : 5.3.22 ]
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808 ) ~ [ spring- webmvc - 5.3.22.jar : 5.3.22 ]
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87 ) ~ [spring - webmvc - 5.3.22.jar : 5.3.22 ]
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1070 ) ~ [ spring- webmvc - 5.3.22.jar : 5.3.22 ]
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963 ) ~ [ spring- webmvc - 5.3.22.jar : 5.3.22 ]
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006 ) [ spring - webmvc - 5.3.22.jar : 5.3.22 ]
    at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909 ) [ spring - webmvc - 5.3.22.jar : 5.3.22 ]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:681 ) [tomcat-embed- core - 9.0.65.jar : 4.0.FR ]
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883 ) [ spring - webmvc - 5.3.22.jar : 5.3.22 ]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:764 ) [tomcat-embed- core - 9.0.65.jar : 4.0.FR ]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227 ) [tomcat- embed - core - 9.0.65.jar : 9.0.65 ]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162 ) [tomcat- embed - core - 9.0.65.jar : 9.0.65 ]
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53 ) [ tomcat-embed - websocket - 9.0.65.jar : 9.0.65 ]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189 ) [tomcat- embed - core - 9.0.65.jar : 9.0.65 ]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162 ) [tomcat- embed - core - 9.0.65.jar : 9.0.65 ]at 
    org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100 ) [ spring- web - 5.3.22.jar : 5.3.22 ]at org.springframework.web.filter.OncePerRequestFilter.doFilter 
    (OncePerRequestFilter.java:117 ) [ spring- web - 5.3.22.jar : 5.3.22 ]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189 ) [tomcat- embed - core - 9.0.65.jar : 9.0.65 ]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162 ) [tomcat- embed - core - 9.0.65.jar : 9.0.65 ]at 
    org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93 ) [ spring- web - 5.3.22.jar : 5.3.22 ]at org.springframework.web.filter.OncePerRequestFilter.doFilter 
    (OncePerRequestFilter.java:117 ) [ spring- web - 5.3.22.jar : 5.3.22 ]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189 ) [tomcat- embed - core - 9.0.65.jar : 9.0.65 ]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162 ) [tomcat- embed - core - 9.0.65.jar : 9.0.65 ]
    at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:96 ) [ spring - boot- actuator - 2.7.2.jar : 2.7.2 ]at org.springframework.web.filter.OncePerRequestFilter.doFilter 
    (OncePerRequestFilter.java:117 ) [ spring- web - 5.3.22.jar : 5.3.22 ]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189 ) [tomcat- embed - core - 9.0.65.jar : 9.0.65 ]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162 ) [tomcat- embed - core - 9.0.65.jar : 9.0.65 ]at 
    org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201 ) [spring - web - 5.3.22.jar : 5.3.22 ]at org.springframework.web.filter.OncePerRequestFilter.doFilter 
    (OncePerRequestFilter.java:117 ) [ spring- web - 5.3.22.jar : 5.3.22 ]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189 ) [tomcat- embed - core - 9.0.65.jar : 9.0.65 ]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162 ) [tomcat- embed - core - 9.0.65.jar : 9.0.65 ]
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197 ) [ tomcat-embed - core - 9.0.65.jar : 9.0.65 ]
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97 ) [ tomcat-embed - core - 9.0.65.jar : 9.0.65 ]
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541 ) [ tomcat-embed - core - 9.0.65.jar : 9.0.65 ]
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135 ) [ tomcat-embed - core - 9.0.65.jar : 9.0.65 ]at org.apache.catalina.valves.ErrorReportValve.invoke 
    (ErrorReportValve.java:92 ) [ tomcat-embed- core - 9.0.65.jar : 9.0.65 ]
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78 ) [ tomcat-embed - core - 9.0.65.jar : 9.0.65 ]at org.apache.catalina.connector.CoyoteAdapter.service 
    (CoyoteAdapter.java:360 ) [ tomcat-embed- core - 9.0.65.jar : 9.0.65 ]at org.apache.coyote.http11.Http11Processor.service 
    (Http11Processor.java:399 ) [ tomcat-embed- core - 9.0.65.jar : 9.0.65 ]
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65 ) [ tomcat-embed - core - 9.0.65.jar : 9.0.65 ]at org.apache.coyote.AbstractProtocol 
    $ConnectionHandler.process(AbstractProtocol.java:890 ) [tomcat-embed - core - 9.0.65.jar : 9.0.65 ]at org.apache.tomcat.util.net.NioEndpoint$ SocketProcessor.doRun 
    (NioEndpoint.java:1789 ) [ tomcat-embed- core - 9.0.65.jar : 9.0.65 ]
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49 ) [ tomcat-embed - core - 9.0.65.jar : 9.0.65 ]
    at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191 ) [ tomcat-embed - core - 9.0.65.jar : 9.0.65 ]
    at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659 ) [ tomcat -embed- core - 9.0.65.jar : 9.0.65 ]at org.apache.tomcat.util.threads.TaskThread 
    $WrappingRunnable.run(TaskThread.java:61 ) [ tomcat-embed- core - 9.0.65.jar : 9.0.65 ]
    at java.lang.Thread.run(Thread.java: 748 ) [na: 1.8.0_301 ]

The entity class is as follows:

import lombok.Data;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import java.util.List;
@Data
public  class OutstoreCodeVO {
    @NotBlank(message = "The outbound order number cannot be empty " )
     private String orderNo;
    
    @Valid
    @NotEmpty(message = "The traceback code array cannot be empty " )
     private List<String> codes;

}

2. Reason analysis: The annotations cannot be recognized due to different versions:

(1), when the version is org.hibernate.validator:hibernate-validator:6.0.13.Final

The imported dependencies are:

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;

(2), when the version is org.hibernate.validator:hibernate-validator:6.2.3.Final

 The imported dependencies must be:

import org.hibernate.validator.constraints.NotBlank;
import org.hibernate.validator.constraints.NotEmpty;

3. Solution: Since the version is version 6.2.3, the package introduced by the @NotBlank and @NotEmpty annotations is changed to:

import org.hibernate.validator.constraints.NotBlank;
import org.hibernate.validator.constraints.NotEmpty;

[Solved] STS Console Error: error unknown mavem Maven Configuration Problem

Description Resource Path Location Type Unknown pom.xml /decision line 1 Maven Configuration Problem

Solution:
Add the following line, and then execute maven update, just fine, I don’t know why.

<packaging>war</packaging>

E.g:

<groupId>com.xxx</groupId>
<artifactId>xxx</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>

[Solved] fastapi error: {“detail”:[{“loc”:[“body”],”msg”:”field required”,”type”:”value_error.missing”}]}

Today, I encountered an error with fastapi and recorded it. The code is as follows:

from typing import *
from fastapi import FastAPI
from pydantic import BaseModel

app = FastAPI()

class User(BaseModel):
    username:str = None
    password:str = None

@app.get("/user")
def hello(user:User):
    return {"username":user.username, "password": user.password}

The reason is that the get request and the head request cannot put the object into it like this, and other request methods can be used. Change it to:

@app.get("/user")
def hello(username:str, password:str):
	return {"username":username, "password":password}

or:

@app.post("/user")
def hello(user:User):
    return {"username":user.username, "password": user.password}

[Solved] Delphi Report Error: Range check error

I didn’t study it deeply, but I got an error when it was compiled under Debug, but it was normal when it was compiled under Release.
Later I found out that the out-of-bounds check is turned on in Debug mode.
Project–> Option–>Delphi Complier–>Compiling–>Runtime Errors–> Range Checking
Turns off out-of-bounds checking by the compiler.
Some of the compilation options are saved in a file with dproj suffix, and the settings will go with the project file.

[Solved] spring boot – JPA–H2 Error: H2 error: “Syntax error in SQL statement … expected identifier“

Error: org.h2.jdbc.JdbcSQLSyntaxErrorException: Syntax error in SQL statement “create table [*]user (id bigint generated by default as identity, email varchar(255), name varchar(255), primary key (id))”; expected “identifier”;

2022-08-31 20:42:26.533  WARN 4996 --- [  restartedMain] o.h.t.s.i.ExceptionHandlerLoggedImpl     : GenerationTarget encountered exception accepting command : Error executing DDL "drop table if exists user CASCADE " via JDBC Statement

org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "drop table if exists user CASCADE " via JDBC Statement
	at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:67) ~[hibernate-core-5.6.10.Final.jar:5.6.10.Final]
	at org.hibernate.tool.schema.internal.SchemaDropperImpl.applySqlString(SchemaDropperImpl.java:387) ~[hibernate-core-5.6.10.Final.jar:5.6.10.Final]
	at org.hibernate.tool.schema.internal.SchemaDropperImpl.applySqlStrings(SchemaDropperImpl.java:371) ~[hibernate-core-5.6.10.Final.jar:5.6.10.Final]
	at org.hibernate.tool.schema.internal.SchemaDropperImpl.dropFromMetadata(SchemaDropperImpl.java:246) ~[hibernate-core-5.6.10.Final.jar:5.6.10.Final]
	at org.hibernate.tool.schema.internal.SchemaDropperImpl.performDrop(SchemaDropperImpl.java:156) ~[hibernate-core-5.6.10.Final.jar:5.6.10.Final]
	at org.hibernate.tool.schema.internal.SchemaDropperImpl.doDrop(SchemaDropperImpl.java:128) ~[hibernate-core-5.6.10.Final.jar:5.6.10.Final]
	at org.hibernate.tool.schema.internal.SchemaDropperImpl.doDrop(SchemaDropperImpl.java:114) ~[hibernate-core-5.6.10.Final.jar:5.6.10.Final]
	at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:157) ~[hibernate-core-5.6.10.Final.jar:5.6.10.Final]
	at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:85) ~[hibernate-core-5.6.10.Final.jar:5.6.10.Final]
	at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:335) ~[hibernate-core-5.6.10.Final.jar:5.6.10.Final]
	at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:471) ~[hibernate-core-5.6.10.Final.jar:5.6.10.Final]
	at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1498) ~[hibernate-core-5.6.10.Final.jar:5.6.10.Final]
	at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:58) ~[spring-orm-5.3.22.jar:5.3.22]
	at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:365) ~[spring-orm-5.3.22.jar:5.3.22]
	at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:409) ~[spring-orm-5.3.22.jar:5.3.22]
	at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:396) ~[spring-orm-5.3.22.jar:5.3.22]
	at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:341) ~[spring-orm-5.3.22.jar:5.3.22]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863) ~[spring-beans-5.3.22.jar:5.3.22]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800) ~[spring-beans-5.3.22.jar:5.3.22]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[spring-beans-5.3.22.jar:5.3.22]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.22.jar:5.3.22]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.22.jar:5.3.22]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.22.jar:5.3.22]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.22.jar:5.3.22]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.22.jar:5.3.22]
	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1154) ~[spring-context-5.3.22.jar:5.3.22]
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:908) ~[spring-context-5.3.22.jar:5.3.22]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.22.jar:5.3.22]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147) ~[spring-boot-2.7.3.jar:2.7.3]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734) ~[spring-boot-2.7.3.jar:2.7.3]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408) ~[spring-boot-2.7.3.jar:2.7.3]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) ~[spring-boot-2.7.3.jar:2.7.3]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) ~[spring-boot-2.7.3.jar:2.7.3]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295) ~[spring-boot-2.7.3.jar:2.7.3]
	at com.lxy.spring.boot.Application.main(Application.java:12) ~[main/:na]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
	at java.base/java.lang.reflect.Method.invoke(Method.java:564) ~[na:na]
	at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) ~[spring-boot-devtools-2.7.3.jar:2.7.3]
Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Syntax error in SQL statement "drop table if exists [*]user CASCADE "; expected "identifier"; SQL statement:
drop table if exists user CASCADE  [42001-214]
	at org.h2.message.DbException.getJdbcSQLException(DbException.java:502) ~[h2-2.1.214.jar:2.1.214]
	at org.h2.message.DbException.getJdbcSQLException(DbException.java:477) ~[h2-2.1.214.jar:2.1.214]
	at org.h2.message.DbException.getSyntaxError(DbException.java:261) ~[h2-2.1.214.jar:2.1.214]
	at org.h2.command.Parser.readIdentifier(Parser.java:5656) ~[h2-2.1.214.jar:2.1.214]
	at org.h2.command.Parser.readIdentifierWithSchema(Parser.java:5616) ~[h2-2.1.214.jar:2.1.214]
	at org.h2.command.Parser.readIdentifierWithSchema(Parser.java:5645) ~[h2-2.1.214.jar:2.1.214]
	at org.h2.command.Parser.parseDrop(Parser.java:2188) ~[h2-2.1.214.jar:2.1.214]
	at org.h2.command.Parser.parsePrepared(Parser.java:776) ~[h2-2.1.214.jar:2.1.214]
	at org.h2.command.Parser.parse(Parser.java:689) ~[h2-2.1.214.jar:2.1.214]
	at org.h2.command.Parser.parse(Parser.java:661) ~[h2-2.1.214.jar:2.1.214]
	at org.h2.command.Parser.prepareCommand(Parser.java:569) ~[h2-2.1.214.jar:2.1.214]
	at org.h2.engine.SessionLocal.prepareLocal(SessionLocal.java:631) ~[h2-2.1.214.jar:2.1.214]
	at org.h2.engine.SessionLocal.prepareCommand(SessionLocal.java:554) ~[h2-2.1.214.jar:2.1.214]
	at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1116) ~[h2-2.1.214.jar:2.1.214]
	at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:237) ~[h2-2.1.214.jar:2.1.214]
	at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:223) ~[h2-2.1.214.jar:2.1.214]
	at com.zaxxer.hikari.pool.ProxyStatement.execute(ProxyStatement.java:94) ~[HikariCP-4.0.3.jar:na]
	at com.zaxxer.hikari.pool.HikariProxyStatement.execute(HikariProxyStatement.java) ~[HikariCP-4.0.3.jar:na]
	at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:54) ~[hibernate-core-5.6.10.Final.jar:5.6.10.Final]
	... 39 common frames omitted

2022-08-31 20:42:26.539  WARN 4996 --- [  restartedMain] o.h.t.s.i.ExceptionHandlerLoggedImpl     : GenerationTarget encountered exception accepting command : Error executing DDL "create table user (id bigint generated by default as identity, email varchar(255), name varchar(255), primary key (id))" via JDBC Statement

org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "create table user (id bigint generated by default as identity, email varchar(255), name varchar(255), primary key (id))" via JDBC Statement
	at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:67) ~[hibernate-core-5.6.10.Final.jar:5.6.10.Final]
	at org.hibernate.tool.schema.internal.SchemaCreatorImpl.applySqlString(SchemaCreatorImpl.java:458) ~[hibernate-core-5.6.10.Final.jar:5.6.10.Final]
	at org.hibernate.tool.schema.internal.SchemaCreatorImpl.applySqlStrings(SchemaCreatorImpl.java:442) ~[hibernate-core-5.6.10.Final.jar:5.6.10.Final]
	at org.hibernate.tool.schema.internal.SchemaCreatorImpl.createFromMetadata(SchemaCreatorImpl.java:325) ~[hibernate-core-5.6.10.Final.jar:5.6.10.Final]
	at org.hibernate.tool.schema.internal.SchemaCreatorImpl.performCreation(SchemaCreatorImpl.java:169) ~[hibernate-core-5.6.10.Final.jar:5.6.10.Final]
	at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation(SchemaCreatorImpl.java:138) ~[hibernate-core-5.6.10.Final.jar:5.6.10.Final]
	at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation(SchemaCreatorImpl.java:124) ~[hibernate-core-5.6.10.Final.jar:5.6.10.Final]
	at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:168) ~[hibernate-core-5.6.10.Final.jar:5.6.10.Final]
	at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:85) ~[hibernate-core-5.6.10.Final.jar:5.6.10.Final]
	at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:335) ~[hibernate-core-5.6.10.Final.jar:5.6.10.Final]
	at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:471) ~[hibernate-core-5.6.10.Final.jar:5.6.10.Final]
	at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1498) ~[hibernate-core-5.6.10.Final.jar:5.6.10.Final]
	at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:58) ~[spring-orm-5.3.22.jar:5.3.22]
	at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:365) ~[spring-orm-5.3.22.jar:5.3.22]
	at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:409) ~[spring-orm-5.3.22.jar:5.3.22]
	at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:396) ~[spring-orm-5.3.22.jar:5.3.22]
	at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:341) ~[spring-orm-5.3.22.jar:5.3.22]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863) ~[spring-beans-5.3.22.jar:5.3.22]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800) ~[spring-beans-5.3.22.jar:5.3.22]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[spring-beans-5.3.22.jar:5.3.22]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.22.jar:5.3.22]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.22.jar:5.3.22]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.22.jar:5.3.22]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.22.jar:5.3.22]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.22.jar:5.3.22]
	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1154) ~[spring-context-5.3.22.jar:5.3.22]
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:908) ~[spring-context-5.3.22.jar:5.3.22]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.22.jar:5.3.22]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147) ~[spring-boot-2.7.3.jar:2.7.3]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734) ~[spring-boot-2.7.3.jar:2.7.3]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408) ~[spring-boot-2.7.3.jar:2.7.3]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) ~[spring-boot-2.7.3.jar:2.7.3]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) ~[spring-boot-2.7.3.jar:2.7.3]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295) ~[spring-boot-2.7.3.jar:2.7.3]
	at com.lxy.spring.boot.Application.main(Application.java:12) ~[main/:na]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
	at java.base/java.lang.reflect.Method.invoke(Method.java:564) ~[na:na]
	at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) ~[spring-boot-devtools-2.7.3.jar:2.7.3]
Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Syntax error in SQL statement "create table [*]user (id bigint generated by default as identity, email varchar(255), name varchar(255), primary key (id))"; expected "identifier"; SQL statement:
create table user (id bigint generated by default as identity, email varchar(255), name varchar(255), primary key (id)) [42001-214]
	at org.h2.message.DbException.getJdbcSQLException(DbException.java:502) ~[h2-2.1.214.jar:2.1.214]
	at org.h2.message.DbException.getJdbcSQLException(DbException.java:477) ~[h2-2.1.214.jar:2.1.214]
	at org.h2.message.DbException.getSyntaxError(DbException.java:261) ~[h2-2.1.214.jar:2.1.214]
	at org.h2.command.Parser.readIdentifier(Parser.java:5656) ~[h2-2.1.214.jar:2.1.214]
	at org.h2.command.Parser.readIdentifierWithSchema(Parser.java:5616) ~[h2-2.1.214.jar:2.1.214]
	at org.h2.command.Parser.readIdentifierWithSchema(Parser.java:5645) ~[h2-2.1.214.jar:2.1.214]
	at org.h2.command.Parser.parseCreateTable(Parser.java:9253) ~[h2-2.1.214.jar:2.1.214]
	at org.h2.command.Parser.parseCreate(Parser.java:6784) ~[h2-2.1.214.jar:2.1.214]
	at org.h2.command.Parser.parsePrepared(Parser.java:763) ~[h2-2.1.214.jar:2.1.214]
	at org.h2.command.Parser.parse(Parser.java:689) ~[h2-2.1.214.jar:2.1.214]
	at org.h2.command.Parser.parse(Parser.java:661) ~[h2-2.1.214.jar:2.1.214]
	at org.h2.command.Parser.prepareCommand(Parser.java:569) ~[h2-2.1.214.jar:2.1.214]
	at org.h2.engine.SessionLocal.prepareLocal(SessionLocal.java:631) ~[h2-2.1.214.jar:2.1.214]
	at org.h2.engine.SessionLocal.prepareCommand(SessionLocal.java:554) ~[h2-2.1.214.jar:2.1.214]
	at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1116) ~[h2-2.1.214.jar:2.1.214]
	at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:237) ~[h2-2.1.214.jar:2.1.214]
	at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:223) ~[h2-2.1.214.jar:2.1.214]
	at com.zaxxer.hikari.pool.ProxyStatement.execute(ProxyStatement.java:94) ~[HikariCP-4.0.3.jar:na]
	at com.zaxxer.hikari.pool.HikariProxyStatement.execute(HikariProxyStatement.java) ~[HikariCP-4.0.3.jar:na]
	at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:54) ~[hibernate-core-5.6.10.Final.jar:5.6.10.Final]
	... 39 common frames omitted

2022-08-31 20:42:26.544  INFO 4996 --- [  restartedMain] o.h.e.t.j.p.i.JtaPlatformInitiator       : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2022-08-31 20:42:26.554  INFO 4996 --- [  restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2022-08-31 20:42:26.961  WARN 4996 --- [  restartedMain] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2022-08-31 20:42:27.321  WARN 4996 --- [  restartedMain] org.thymeleaf.templatemode.TemplateMode  : [THYMELEAF][restartedMain] Template Mode 'HTML5' is deprecated. Using Template Mode 'HTML' instead.
2022-08-31 20:42:27.568  INFO 4996 --- [  restartedMain] o.s.b.d.a.OptionalLiveReloadServer       : LiveReload server is running on port 35729
2022-08-31 20:42:27.648  INFO 4996 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2022-08-31 20:42:27.669  INFO 4996 --- [  restartedMain] com.lxy.spring.boot.Application          : Started Application in 7.132 seconds (JVM running for 9.48)

Reason for error: Hibernate/JPA generated table conflicts with database reserved words in the User class I created as follows.

@Entity
public class User {

    @Id //main key
    @GeneratedValue(strategy = GenerationType.IDENTITY) //self increment strategy
    private Long id ;//Unique identification of the entity
    private String name;
    private String email;

    protected User(){

    }

    public User(Long id, String name, String email){

        this.email = email;
        this.id = id;
        this.name = name;

    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    @Override
    public String toString(){

        return  String.format("User[id=%d,name='%s',email='%s']",id,name,email);

    }

}

‘user’ conflicts with database reserved word

Solution : Modify the table name and add the following line:

@Table(name="UserLxy")

Re-run the program and remove the fault

Uncaught URIError: URI malformed [How to Solve]

Uncaught URIError: URI malformed

  • url, pass the value, if the key has Chinese characters inside, the browser will be encoded off by default, so this page needs to be decoded first when calling the query interface), the above error occurs.
  • Because the url contains the “%” character, the browser will give an error when it executes decodeURIComponent on “%”.

Repeat the problem

The browser url on the splice on (?q=%好的);

https://www.baidu.com/?q=%好的

Enter the code;

location.search
'?q=%%E5%A5%BD%E7%9A%84'
decodeURIComponent('%%E5%A5%BD%E7%9A%84');

Solution

urlStr.replace(/%/g, '%25');

Fundamentally solve the problem: encode the URL before uploading the value

encodeURIComponent('%好的');
'%25%E5%A5%BD%E7%9A%84'
https://www.baidu.com/?q=%25%E5%A5%BD%E7%9A%84

[Solved] Internal Error: EPERM: operation not permitted, open

When installing yarn on nodejs (my version: 16.17), after executing the command: corepack enable, I got an error: Internal Error: EPERM: operation not permitted, open 'Y:\nodejs-v16.17.0-x64\pnpm, The operation is not allowed, I thought of the previous execution of rm -rf /* with linux normal user will also prompt not allowed to execute the operation, and change to root (administrator) account to have higher privileges to execute the command, so I guess it should be the same problem, so I tried to run the cmd command window as administrator, and execute the command: corepack enable again, it succeeded It worked:

[Solved] Laravel Create Data Table Error: Syntax error or access violation: 1071 Specified key was too long

1. Scene

  • Version:Laravel 5.7
  • Project downloaded from github, installed locally.

1. Create a new database
2. Execute the data table generation command in the project root directory (non-public directory) , and an php artisan migrateerror is reported:Syntax error or access violation: 1071 Specified key was too long

2. Screenshot of error reporting

  • The migrations table was successfully generated
  • An error was reported when generating the user table
  • So there are 2 tables in the database, migrations and user table

3. Solution

  • Open app/prpvider/appserviceprovider.php file
  • Find the boot() method
  • Set the default length of the string: Schema::defaultStringLength(191);
  • The screenshot is as follows:

4. Re-execute PHP artisan migrate again

  • The error message is as follows:
  • Delete the migrations and user tables in conflict.
  • execute again: php artist migrate the data table is created successfully, as shown in the following figure: