Category Archives: JAVA

[Solved]Error:java: Compilation failed: internal java compiler error

When you use Idea to import a new project or upgrade an idea or create a new project, the following exception information appears:

Error:java: Compilation failed: internal java compiler error 

This error is mainly caused by the jdk version. There are two reasons: the compiled version does not match, and the current project jdk version does not support it.

Solution:

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

[Solved] Arthas failed to bind telnet or http port! Telnet port: 3658, http port: 8563;Error creating bean

[Arthas failed to bind telnet or http port! Telnet port: 3658, http port: 8563; Error creating bean with name ‘documentationPluginsBootstrapper’ defined in URL; Error creating bean with name ‘webMvcRequestHandlerProvider’ defined in URL]

Cause analysis:

Error will be reported when two identical items are started: port conflict!!! (Even if the ports of the two projects are different in the yml file, an error will be reported.)
Arthas failed to bind telnet or http port! Telnet port: 3658, http port: 8563


Solution:

Comment out the arthas in two projects.

<!--        Monitor system performance: do not allow two identical projects to run; comment to enable two  -->
<!--        <dependency>-->
<!--            <groupId>com.taobao.arthas</groupId>-->
<!--            <artifactId>arthas-spring-boot-starter</artifactId>-->
<!--            <version>3.6.0</version>-->
<!--        </dependency>-->

Arthas is an online monitoring and diagnosis product. It can view the status information of application load, memory, gc, and threads in real time from a global perspective, and diagnose business problems without modifying the application code, including checking the access parameters and exceptions of method calls, time-consuming monitoring method execution, class loading information, etc., greatly improving the efficiency of online problem troubleshooting.

Error 1

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'documentationPluginsBootstrapper' defined in URL 
[jar:file:/D:/JAVA1/scm-repository/io/springfox/springfox-spring-web/3.0.0/springfox-spring-web-3.0.0.jar!/springfox/documentation/spring/web/plugins/DocumentationPluginsBootstrapper.class]: 
Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException:
 Error creating bean with name 'webMvcRequestHandlerProvider' defined in URL 
 [jar:file:/D:/JAVA1/scm-repository/io/springfox/springfox-spring-webmvc/3.0.0/springfox-spring-webmvc-3.0.0.jar!/
 springfox/documentation/spring/web/plugins/WebMvcRequestHandlerProvider.class]: Unsatisfied dependency expressed through constructor parameter 2; nested exception is org.springframework.beans.factory.BeanCreationException:
  Error creating bean with name 'webEndpointServletHandlerMapping' defined in class path resource [org/springframework/boot/actuate/autoconfigure/endpoint/web/servlet/WebMvcEndpointManagementContextConfiguration.class]: 
  Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate 
  [org.springframework.boot.actuate.endpoint.web.servlet.WebMvcEndpointHandlerMapping]: Factory method 'webEndpointServletHandlerMapping' threw exception;
   nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'arthasEndPoint': Unsatisfied dependency expressed through field 'arthasAgent'; nested exception is 
   org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'arthasAgent' defined in class path resource 
   [com/alibaba/arthas/spring/ArthasConfiguration.class]: Bean instantiation via factory method failed; nested exception is 
   org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.taobao.arthas.agent.attach.ArthasAgent]: Factory method 'arthasAgent' threw exception; nested exception is java.lang.IllegalStateException: 
   java.lang.reflect.InvocationTargetException


Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'webMvcRequestHandlerProvider' defined in URL 
[jar:file:/D:/JAVA1/scm-repository/io/springfox/springfox-spring-webmvc/3.0.0/springfox-spring-webmvc-
3.0.0.jar!/springfox/documentation/spring/web/plugins/WebMvcRequestHandlerProvider.class]: Unsatisfied dependency expressed through constructor parameter 2; nested exception is org.springframework.beans.factory.BeanCreationException: Error 
creating bean with name 'webEndpointServletHandlerMapping' defined in class path resource 
[org/springframework/boot/actuate/autoconfigure/endpoint/web/servlet/WebMvcEndpointManagementContextConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate 
[org.springframework.boot.actuate.endpoint.web.servlet.WebMvcEndpointHandlerMapping]: Factory method 'webEndpointServletHandlerMapping' threw exception;
 nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'arthasEndPoint': Unsatisfied dependency expressed through field 'arthasAgent'; nested exception is 
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'arthasAgent' defined in class path resource 
[com/alibaba/arthas/spring/ArthasConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: 
Failed to instantiate [com.taobao.arthas.agent.attach.ArthasAgent]: Factory method 'arthasAgent' threw exception; nested exception is java.lang.IllegalStateException: java.lang.reflect.InvocationTargetException

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate 
[org.springframework.boot.actuate.endpoint.web.servlet.WebMvcEndpointHandlerMapping]: Factory method 'webEndpointServletHandlerMapping' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: 
Error creating bean with name 'arthasEndPoint': Unsatisfied dependency expressed through field 'arthasAgent'; nested exception is 
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'arthasAgent' defined in class path resource [com/alibaba/arthas/spring/ArthasConfiguration.class]: Bean instantiation via factory method failed; nested exception is 
org.springframework.beans.BeanInstantiationException: Failed to instantiate 
[com.taobao.arthas.agent.attach.ArthasAgent]: Factory method 'arthasAgent' threw exception; nested exception is java.lang.IllegalStateException: 
java.lang.reflect.InvocationTargetException

	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
	
	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653)
	... 57 common frames omitted
	
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'arthasEndPoint': Unsatisfied dependency expressed through field 'arthasAgent'; nested exception is 
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'arthasAgent' defined in class path resource 
[com/alibaba/arthas/spring/ArthasConfiguration.class]: Bean instantiation via factory method failed; nested exception is 
org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.taobao.arthas.agent.attach.ArthasAgent]: 
Factory method 'arthasAgent' threw exception; nested exception is java.lang.IllegalStateException: java.lang.reflect.InvocationTargetException

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'arthasAgent' defined in class path resource 
[com/alibaba/arthas/spring/ArthasConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.taobao.arthas.agent.attach.ArthasAgent]: Factory method 'arthasAgent' threw exception; nested exception is java.lang.IllegalStateException: 
java.lang.reflect.InvocationTargetException

Caused by: java.lang.IllegalStateException: Arthas failed to bind telnet or http port! Telnet port: 3658, http port: 8563

	at com.taobao.arthas.core.server.ArthasBootstrap.bind(ArthasBootstrap.java:448)
	at com.taobao.arthas.core.server.ArthasBootstrap.<init>
	(ArthasBootstrap.java:156)
	at com.taobao.arthas.core.server.ArthasBootstrap.getInstance(ArthasBootstrap.java:581)
	... 112 common frames omitted
Disconnected from the target VM, address: '127.0.0.1:58928', transport: 'socket'


Error creating bean with name 'arthasEndPoint': Unsatisfied dependency expressed through field 'arthasAgent'; nested exception is 
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'arthasAgent' defined in class path resource 
[com/alibaba/arthas/spring/ArthasConfiguration.class]: Bean instantiation via factory method failed; nested exception is 
org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.taobao.arthas.agent.attach.ArthasAgent]: 
Factory method 'arthasAgent' threw exception; nested exception is java.lang.IllegalStateException: java.lang.reflect.InvocationTargetException

Error 2

2022-09-08 13:33:15 [main] INFO  c.b.d.d.DynamicRoutingDataSource
 - dynamic-datasource - add a datasource named [master] success
2022-09-08 13:33:15 [main] INFO  c.b.d.d.DynamicRoutingDataSource
 - dynamic-datasource initial loaded [2] datasource,primary datasource named [master]
Registered plugin: 'com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor@136cad3e'
Parsed mapper file: 'URL [jar:file:/D:/JAVA1/scm-repository/com/skeqi/manage-service/1.0.1/manage-service-1.0.1.jar!/mybatisplus/system/PrCompanyMapper.xml]'
Parsed mapper file: 'URL [jar:file:/D:/JAVA1/scm-repository/com/skeqi/manage-service/1.0.1/manage-service-1.0.1.jar!/mybatisplus/system/SysConfigMapper.xml]'
Parsed mapper file: 'URL [jar:file:/D:/JAVA1/scm-repository/com/skeqi/manage-service/1.0.1/manage-service-1.0.1.jar!/mybatisplus/system/SysDeptMapper.xml]'
Parsed mapper file: 'URL [jar:file:/D:/JAVA1/scm-repository/com/skeqi/manage-service/1.0.1/manage-service-1.0.1.jar!/mybatisplus/system/SysDeptRankMapper.xml]'
Parsed mapper file: 'URL [jar:file:/D:/JAVA1/scm-repository/com/skeqi/manage-service/1.0.1/manage-service-1.0.1.jar!/mybatisplus/system/SysDictDataMapper.xml]'
Parsed mapper file: 'URL [jar:file:/D:/JAVA1/scm-repository/com/skeqi/manage-service/1.0.1/manage-service-1.0.1.jar!/mybatisplus/system/SysDictTypeMapper.xml]'
Parsed mapper file: 'URL [jar:file:/D:/JAVA1/scm-repository/com/skeqi/manage-service/1.0.1/manage-service-1.0.1.jar!/mybatisplus/system/SysLogininforMapper.xml]'
Parsed mapper file: 'URL [jar:file:/D:/JAVA1/scm-repository/com/skeqi/manage-service/1.0.1/manage-service-1.0.1.jar!/mybatisplus/system/SysMenuMapper.xml]'
Parsed mapper file: 'URL [jar:file:/D:/JAVA1/scm-repository/com/skeqi/manage-service/1.0.1/manage-service-1.0.1.jar!/mybatisplus/system/SysNoticeMapper.xml]'
Parsed mapper file: 'URL [jar:file:/D:/JAVA1/scm-repository/com/skeqi/manage-service/1.0.1/manage-service-1.0.1.jar!/mybatisplus/system/SysOperLogMapper.xml]'
Parsed mapper file: 'URL [jar:file:/D:/JAVA1/scm-repository/com/skeqi/manage-service/1.0.1/manage-service-1.0.1.jar!/mybatisplus/system/SysPostMapper.xml]'
Can not find table primary key in Class: "com.skeqi.manage.domain.SysRoleDept".
Parsed mapper file: 'URL [jar:file:/D:/JAVA1/scm-repository/com/skeqi/manage-service/1.0.1/manage-service-1.0.1.jar!/mybatisplus/system/SysRoleDeptMapper.xml]'
Parsed mapper file: 'URL [jar:file:/D:/JAVA1/scm-repository/com/skeqi/manage-service/1.0.1/manage-service-1.0.1.jar!/mybatisplus/system/SysRoleMapper.xml]'
Can not find table primary key in Class: "com.skeqi.manage.domain.SysRoleMenu".
Parsed mapper file: 'URL [jar:file:/D:/JAVA1/scm-repository/com/skeqi/manage-service/1.0.1/manage-service-1.0.1.jar!/mybatisplus/system/SysRoleMenuMapper.xml]'
Parsed mapper file: 'URL [jar:file:/D:/JAVA1/scm-repository/com/skeqi/manage-service/1.0.1/manage-service-1.0.1.jar!/mybatisplus/system/SysUserMapper.xml]'
Can not find table primary key in Class: "com.skeqi.manage.domain.SysUserPost".
Parsed mapper file: 'URL [jar:file:/D:/JAVA1/scm-repository/com/skeqi/manage-service/1.0.1/manage-service-1.0.1.jar!/mybatisplus/system/SysUserPostMapper.xml]'
Can not find table primary key in Class: "com.skeqi.manage.domain.SysUserRole".
Parsed mapper file: 'URL [jar:file:/D:/JAVA1/scm-repository/com/skeqi/manage-service/1.0.1/manage-service-1.0.1.jar!/mybatisplus/system/SysUserRoleMapper.xml]'
 _ _   |_  _ _|_. ___ _ |    _ 
| | |\/|_)(_| | |_\  |_)||_|_\ 
    /              |         
                        3.4.3 
Disconnected from the target VM, address: '127.0.0.1:50626', transport: 'socket'

Process finished with exit code -1073740940 (0xC0000374)

Mybatis Error: Error instantiating class bakou.entity.Person with invalid types () or value)

Error instantiating class bakou.entity.Person with invalid types () or values (). Cause: java.lang.NoSuchMethodException: bakou.entity.Person.<init>()


Reason: Only a parameterized constructor is added to the entity class, no parameterless constructor is provided

Solution: Add a construction method in the entity class without parameters

The essence of the problem: Instantiate the object with a method that uses an uninvolved construct to instantiate the object


The error page is as follows:

org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: org.apache.ibatis.reflection.ReflectionException: Error instantiating class bakou.entity.Person with invalid types () or values (). Cause: java.lang.NoSuchMethodException: bakou.entity.Person.<init>()
### The error may exist in bakou/dao/PersonDaoMapper.xml
### The error may involve bakou.dao.PersonDao.selectById-Inline
### The error occurred while setting parameters
### SQL: select p.id,name,phone,c.id cid,cardno,address,expire         from person p                  join card c         on p.card_id = c.id where p.id = ?;
### Cause: org.apache.ibatis.reflection.ReflectionException: Error instantiating class bakou.entity.Person with invalid types () or values (). Cause: java.lang.NoSuchMethodException: bakou.entity.Person.<init>()

	at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:23)
	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:104)
	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:95)
	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:59)
	at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:95)
	at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:40)
	at com.sun.proxy.$Proxy5.selectById(Unknown Source)
	at bakou.test.TestPersonDao.testPersonDao(TestPersonDao.java:21)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
	at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
	at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
	at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
	at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
	at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
	at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)
Caused by: org.apache.ibatis.reflection.ReflectionException: Error instantiating class bakou.entity.Person with invalid types () or values (). Cause: java.lang.NoSuchMethodException: bakou.entity.Person.<init>()
	at org.apache.ibatis.reflection.factory.DefaultObjectFactory.instantiateClass(DefaultObjectFactory.java:83)
	at org.apache.ibatis.reflection.factory.DefaultObjectFactory.create(DefaultObjectFactory.java:45)
	at org.apache.ibatis.reflection.factory.DefaultObjectFactory.create(DefaultObjectFactory.java:38)
	at org.apache.ibatis.executor.resultset.FastResultSetHandler.createResultObject(FastResultSetHandler.java:376)
	at org.apache.ibatis.executor.resultset.FastResultSetHandler.createResultObject(FastResultSetHandler.java:355)
	at org.apache.ibatis.executor.resultset.NestedResultSetHandler.getRowValue(NestedResultSetHandler.java:137)
	at org.apache.ibatis.executor.resultset.NestedResultSetHandler.getRowValue(NestedResultSetHandler.java:122)
	at org.apache.ibatis.executor.resultset.NestedResultSetHandler.handleRowValues(NestedResultSetHandler.java:108)
	at org.apache.ibatis.executor.resultset.NestedResultSetHandler.handleResultSet(NestedResultSetHandler.java:76)
	at org.apache.ibatis.executor.resultset.FastResultSetHandler.handleResultSets(FastResultSetHandler.java:152)
	at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:57)
	at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:70)
	at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:57)
	at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:267)
	at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:141)
	at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:105)
	at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:81)
	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:101)
	... 34 more
Caused by: java.lang.NoSuchMethodException: bakou.entity.Person.<init>()
	at java.lang.Class.getConstructor0(Class.java:3082)
	at java.lang.Class.getDeclaredConstructor(Class.java:2178)
	at org.apache.ibatis.reflection.factory.DefaultObjectFactory.instantiateClass(DefaultObjectFactory.java:57)
	... 51 more

The solution is as follows (no parameter structure is provided)

    public Person() {
    }

    public Person(Integer personId, String name, String phone, Card card) {
        this.personId = personId;
        this.name = name;
        this.phone = phone;
        this.card = card;
    }

[Solved] TStatus(statusCode:ERROR_STATUS, sqlState:HY000, errorMessage:IllegalStateException: null

TStatus(statusCode:ERROR_STATUS, sqlState:HY000, errorMessage:IllegalStateException: null 

Solution:

select t1.citycode,count(distinct t1.cardno,t1.ndate) cnt,round(sum(t1.amount),2) amount from t2

inner join t1 on t1.cardno = t2.cardno

group by citycode

Execute the SQL commands above and report the following error:

SQL ERROR [500051] [HY000]: [Cloudera][ImpalaJDBCDriver](500051) ERROR processing query/statement. Error Code: 0, SQL state: TStatus(statusCode:ERROR_STATUS, sqlState:HY000, errorMessage:IllegalStateException: null

Adjust the position of count(distinct t1.cardno,t1.ndate) and there will be no problem

ERROR [Executor task launch worker for task 30867] NebulaEdgeWriter:52 – failed to write

ERROR [Executor task launch worker for task 30867] NebulaEdgeWriter:52 – failed to write

11:32:16,614 ERROR [Executor task launch worker for task 30867] NebulaEdgeWriter:52 - failed to write INSERT edge `SUPPLIER_AVERAGE_QUOTA`(`four_level_name`,`start_time`,`push_time`,`quote_cycle`) VALUES -7708723366638923441->-7708723366638923441@6325772268643779185: ("Shock Absorber", "2022-05-16 18:25:24", "2022-05-17 09:57:34", "2") for Storage Error: More than one request trying to add/update/delete one edge/vertex at the same time.
11:32:16,614 ERROR [Executor task launch worker for task 30868] NebulaEdgeWriter:52 - failed to write INSERT edge `SUPPLIER_AVERAGE_QUOTA`(`four_level_name`,`start_time`,`push_time`,`quote_cycle`) VALUES -7708723366638923441->-7708723366638923441@6325772268643779185: ("Shock Absorber", "2022-05-16 18:25:24", "2022-05-17 09:57:34", "2") for Storage Error: More than one request trying to add/update/delete one edge/vertex at the same time.
11:32:18,658 ERROR [Executor task launch worker for task 30901] NebulaEdgeWriter:52 - failed to write INSERT edge `SUPPLIER_AVERAGE_QUOTA`(`four_level_name`,`start_time`,`push_time`,`quote_cycle`) VALUES 8524141067397973150->8524141067397973150@-2616939442014903388: ("Color Paint", "2022-01-15 17:11:57", "2022-01-17 17:20:07", "3") for Storage Error: More than one request trying to add/update/delete one edge/vertex at the same time.
11:32:22,097 ERROR [main] NebulaDataSourceEdgeWriter:98 - failed execs:
 List(INSERT edge `SUPPLIER_AVERAGE_QUOTA`(`four_level_name`,`start_time`,`push_time`,`quote_cycle`) VALUES -7708723366638923441->-7708723366638923441@6325772268643779185: ("Shock Absorber", "2022-05-16 18:25:24", "2022-05-17 09:57:34", "2"))
11:32:22,097 ERROR [main] NebulaDataSourceEdgeWriter:98 - failed execs:
 List(INSERT edge `SUPPLIER_AVERAGE_QUOTA`(`four_level_name`,`start_time`,`push_time`,`quote_cycle`) VALUES -7708723366638923441->-7708723366638923441@6325772268643779185: ("Shock Absorber", "2022-05-16 18:25:24", "2022-05-17 09:57:34", "2"))
11:32:22,097 ERROR [main] NebulaDataSourceEdgeWriter:98 - failed execs:
 List(INSERT edge `SUPPLIER_AVERAGE_QUOTA`(`four_level_name`,`start_time`,`push_time`,`quote_cycle`) VALUES 8524141067397973150->8524141067397973150@-2616939442014903388: ("Color Paint", "2022-01-15 17:11:57", "2022-01-17 17:20:07", "3"))

 

Solution: The data should be skewed, add this when partitioning can be

[Solved] Error updating database. Cause: java.sql.SQLException: Unknown initial character set index ‘255‘ re

The following problem was suddenly reported as an error while conducting the test:
Error updating database.  Cause: java.sql.SQLException: Unknown initial character set index ‘255’ received from server. Initial client character set can be forced via the ‘characterEncoding’ property.
Error:

org.apache.ibatis.exceptions.PersistenceException: 
### Error updating database.  Cause: java.sql.SQLException: Unknown initial character set index '255' received from server. Initial client character set can be forced via the 'characterEncoding' property.
### Cause: java.sql.SQLException: Unknown initial character set index '255' received from server. Initial client character set can be forced via the 'characterEncoding' property.

	at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
	at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:200)
	at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:185)
	at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:57)
	at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59)
	at com.sun.proxy.$Proxy12.insertEncodeProperties(Unknown Source)
	at test.MyTest.test1(MyTest.java:50)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
	at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:220)
	at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:53)
Caused by: java.sql.SQLException: Unknown initial character set index '255' received from server. Initial client character set can be forced via the 'characterEncoding' property.

jdbc.properties file

Solution: If the error prompt is a character encoding problem, add the character encoding setting after the URL

jdbc.url=jdbc:mysql:///mybatis_test_db?characterEncoding=utf8

[Solved] Jenkins Publish to rancher Error: ERROR: Build step failed with exception java.lang.ClassCastException: class com.

error message

ERROR: Build step failed with exception
java.lang.ClassCastException: class com.fasterxml.jackson.databind.node.NullNode cannot be cast to class com.fasterxml.jackson.databind.node.ObjectNode (com.fasterxml.jackson.databind.node.NullNode and com.fasterxml.jackson.databind.node.ObjectNode are in unnamed module of loader jenkins.util.AntClassLoader @3e61f18f)
	at io.jenkins.plugins.rancher2.Rancher2RedeployBuilder.perform(Rancher2RedeployBuilder.java:136)
	at jenkins.tasks.SimpleBuildStep.perform(SimpleBuildStep.java:123)
	at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:78)
	at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:806)
	at hudson.model.Build$BuildExecution.build(Build.java:198)
	at hudson.model.Build$BuildExecution.doRun(Build.java:163)
	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:514)
	at hudson.model.Run.execute(Run.java:1888)
	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
	at hudson.model.ResourceController.execute(ResourceController.java:99)
	at hudson.model.Executor.run(Executor.java:432)
Build step 'Redeploy Rancher2.x Workload' marked build as failure

How to Solve:

When publishing to the router, the corresponding node cannot be found, so confirm whether the router path configuration in jenkins is correct. The following two paths must be consistent:

The router configuration in jenkins

The actual router path

[Solved] Error attempting to get column ‘xxxx_time‘ from result set. Cause: java.sql.SQLFeatureNotSupportedEx

Error Message:
Servlet.service() for servlet [dispatcherServlet] in context with path [/security] threw exception [Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessApiUsageException: Error attempting to get column 'xxxx_ime' from result set.  Cause: java.sql.SQLFeatureNotSupportedException
; null; nested exception is java.sql.SQLFeatureNotSupportedException] with root cause

 

Error Cause
Java entity class in the field used LocalDateTime type, in the conversion time error: Error attempting to get column ‘xxxx_ime’ from result set……..

Solution:
1. upgrade druid version to 1.1.22 or above to eliminate the problem

2. Change the entity class date type to java.util.

[Solved] error running ‘xx‘ Command line is too long shorten command line for xx or also for Spring Boot defa

Problem description:

This problem occurred when the idea started the microservice project, causing the project to fail to start

error running ‘xx’ Command line is too long shorten command line for xx or also for Spring Boot default configuration.

Solution:

My idea uses the 2019 version.

Step 1: Open edit Configurations

Step 2:

Modify shorten command line to JAR manifest.

Restart, complete.

[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] 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] springsecurity custom exceptions: Error: Parse Error: Response overflow

preface

In the process of writing the project, using springsecurity for permission management and customizing the token filter to be added before the authentication filter, there was a problem where the exception handling mechanism of springsecurity would be called when the token expired, instead of using my global exception handling

Solution:

Custom filter

package com.fruiter.filter;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.jsonwebtoken.ExpiredJwtException;
import org.springframework.web.filter.OncePerRequestFilter;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Handling exceptions thrown by Controller will be handled by this filter
 */
public class ControllerExceptionFilter extends OncePerRequestFilter {

    @Override
    protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
        try {
            filterChain.doFilter(request, response);
        } catch (ExpiredJwtException e) {
            e.printStackTrace();

            response.setStatus(401);
            response.setContentType("application/json");
            response.setCharacterEncoding("utf-8");
            response.getWriter().print("token过期");
        }
    }

    public String convertObjectToJson(Object object) throws JsonProcessingException {
        if (object == null) {
            return null;
        }
        ObjectMapper mapper = new ObjectMapper();
        return mapper.writeValueAsString(object);
    }
}

Join for management

//WebAsyncManagerIntegrationFilter is the first exception handling filter
http.addFilterBefore(new ControllerExceptionFilter(), WebAsyncManagerIntegrationFilter.class);

be careful

Here, set the status code for response, that is, response.setStatus(401);
you can’t set an excessively large number such as 10010, otherwise an error will report error: parse error: response overflow

Modify it to 401.