Springboot3原生镜像打包问题记录

        听说SpringBoot3版本支持直接生成原生镜像,正好项目上需要开发一个新的模块,所以使用了最新的SpringBoot3.1.0版本搭建框架,进行开发。本文主要记录生成原生镜像过程中遇到的问题。

        采用的技术栈:

  1. SpringBoot 3.1.0
  2. knife4j 4.1.0
  3. mybatis-plus 3.5.3.1

        打包环境:

  1. CentOS Linux release 7.9.2009 (Core)
  2. Java(TM) SE Runtime Environment Oracle GraalVM 17.0.7+8.1 (build 17.0.7+8-LTS-jvmci-23.0-b12)

首先根据SpringBoot官网的说明,进行框架搭建。

GraalVM Native Image Support (spring.io)

使用了最简单的SpringBoot的web项目,进行打包,试运行。

D:\github\spring-native-demo>target\demo.exe

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v3.1.1)

2023-07-06T15:03:38.052+08:00  INFO 25832 --- [           main] n.k.d.server.DemoApplication             : Starting AOT-processed DemoApplication using Java 17.0.7 with PID 25832 (D:\github\spring-native-demo\target\demo.exe started by Administrator in D:\github\spring-native-demo)
2023-07-06T15:03:38.052+08:00  INFO 25832 --- [           main] n.k.d.server.DemoApplication             : No active profile set, falling back to 1 default profile: "default"
2023-07-06T15:03:38.093+08:00  INFO 25832 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8081 (http)
2023-07-06T15:03:38.094+08:00  INFO 25832 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2023-07-06T15:03:38.094+08:00  INFO 25832 --- [           main] o.apache.catalina.core.StandardEngine    : Starting Servlet engine: [Apache Tomcat/10.1.10]
2023-07-06T15:03:38.100+08:00  INFO 25832 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2023-07-06T15:03:38.100+08:00  INFO 25832 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 48 ms
2023-07-06T15:03:38.122+08:00  INFO 25832 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8081 (http) with context path ''
2023-07-06T15:03:38.137+08:00  INFO 25832 --- [           main] n.k.d.server.DemoApplication             : Started DemoApplication in 0.096 seconds (process running for 0.099)
2023-07-06T15:03:38.137+08:00  INFO 25832 --- [           main] n.k.d.server.DemoApplication             : 服务启动成功!Spring Boot版本:[3.1.1] ,Spring版本:[6.0.10]
2023-07-06T15:04:10.174+08:00  INFO 25832 --- [nio-8081-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2023-07-06T15:04:10.174+08:00  INFO 25832 --- [nio-8081-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2023-07-06T15:04:10.174+08:00  INFO 25832 --- [nio-8081-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 0 ms

96ms启动了一个springBoot项目(当然,这个项目本身也只要1.x秒就可以起来了,)

好像挺顺利的,让我对Springboot对Native的支持有了一份谜之自信(好吧,这就无尽深渊的开始)。 

所以,一股脑儿将新项目的代码都迁移进来了,结果看如下记录。

Mybatis部分pom文件如下:

		<dependency>
			<groupId>mysql</groupId>
			<artifactId>mysql-connector-java</artifactId>
			<scope>runtime</scope>
			<version>8.0.33</version>
		</dependency>

		<dependency>
			<groupId>com.baomidou</groupId>
			<artifactId>mybatis-plus-boot-starter</artifactId>
			<version>3.5.3.1</version>
			<exclusions>
				<exclusion>
					<artifactId>mybatis</artifactId>
					<groupId>org.mybatis</groupId>
				</exclusion>
			</exclusions>
		</dependency>

		<dependency>
			<groupId>org.mybatis</groupId>
			<artifactId>mybatis</artifactId>
			<version>3.5.13</version>
		</dependency>

因为Mybatis-Plus自带的Mybatis版本不支持Native特性,所以单独添加了Mybatis最新版本。

首先报错的是日志,运行时,显示无法找到日志相关的类。


  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v3.1.1)

2023-07-06T15:50:08.843+08:00  INFO 17912 --- [           main] n.k.d.server.DemoApplication             : Starting AOT-processed DemoApplication using Java 17.0.7 with PID 17912 (D:\github\spring-native-demo\target\demo.exe started by Administrator in D:\github\spring-native-demo)
2023-07-06T15:50:08.843+08:00  INFO 17912 --- [           main] n.k.d.server.DemoApplication             : No active profile set, falling back to 1 default profile: "default"
2023-07-06T15:50:08.845+08:00 ERROR 17912 --- [           main] o.s.boot.SpringApplication               : Application run failed

java.lang.ExceptionInInitializerError: null
        at org.mybatis.spring.mapper.MapperScannerConfigurer.postProcessBeanDefinitionRegistry(MapperScannerConfigurer.java:357) ~[demo.exe:2.0.7]
        at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:344) ~[na:na]
        at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:145) ~[na:na]
        at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:771) ~[demo.exe:6.0.10]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:589) ~[demo.exe:6.0.10]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[demo.exe:3.1.1]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734) ~[demo.exe:3.1.1]
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:436) ~[demo.exe:3.1.1]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:312) ~[demo.exe:3.1.1]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) ~[demo.exe:3.1.1]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295) ~[demo.exe:3.1.1]
        at net.keepsoft.deploypoolscheduler.server.DemoApplication.main(DemoApplication.java:16) ~[demo.exe:na]
Caused by: org.apache.ibatis.logging.LogException: Error creating logger for logger org.mybatis.spring.mapper.ClassPathMapperScanner.  Cause: java.lang.NullPointerException
        at org.apache.ibatis.logging.LogFactory.getLog(LogFactory.java:54) ~[na:na]
        at org.apache.ibatis.logging.LogFactory.getLog(LogFactory.java:47) ~[na:na]
        at org.mybatis.logging.LoggerFactory.getLogger(LoggerFactory.java:32) ~[na:na]
        at org.mybatis.spring.mapper.ClassPathMapperScanner.<clinit>(ClassPathMapperScanner.java:59) ~[na:na]
        ... 12 common frames omitted
Caused by: java.lang.NullPointerException: null
        at org.apache.ibatis.logging.LogFactory.getLog(LogFactory.java:52) ~[na:na]
        ... 15 common frames omitted

在src\main\resources\META-INF\native-image\org.mybatis\mybatis\3.5.13添加reflect-config.json,文件内容:

[{
  "name": "org.apache.ibatis.logging.slf4j.Slf4jImpl",
  "allDeclaredFields": true,
  "allDeclaredConstructors": true,
  "allDeclaredMethods": true,
  "allPublicMethods": true,
  "allDeclaredClasses": true
},
{
"name": "org.slf4j.Marker",
"allDeclaredFields": true,
"allDeclaredConstructors": true,
"allDeclaredMethods": true,
"allPublicMethods": true,
"allDeclaredClasses": true
}]

接着是internalConfigurationAnnotationProcessor


   .   ____          _            __ _ _

  /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \

 ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \

  \\/  ___)| |_)| | | | | || (_| |  ) ) ) )

   '  |____| .__|_| |_|_| |_\__, | / / / /

  =========|_|==============|___/=/_/_/_/

  :: Spring Boot ::                (v3.1.0)

 

 2023-06-26T00:27:50.987Z  INFO 1 --- [           main] n.k.deploypoolscheduler.DpsApplication   : Starting AOT-processed DpsApplication using Java 17.0.7 with PID 1 (/workspace/net.keepsoft.deploypoolscheduler.DpsApplication started by cnb in /workspace)

 2023-06-26T00:27:50.987Z  INFO 1 --- [           main] n.k.deploypoolscheduler.DpsApplication   : No active profile set, falling back to 1 default profile: "default"

 2023-06-26T00:27:50.994Z  WARN 1 --- [           main] o.m.s.mapper.ClassPathMapperScanner      : No MyBatis mapper was found in '[net.keepsoft.deploypoolscheduler.mapper]' package. Please check your configuration.

 2023-06-26T00:27:50.995Z  WARN 1 --- [           main] w.s.c.ServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.context.annotation.internalConfigurationAnnotationProcessor': Failed to instantiate [org.springframework.context.annotation.ConfigurationClassPostProcessor]: No default constructor found

 2023-06-26T00:27:50.997Z ERROR 1 --- [           main] o.s.boot.SpringApplication               : Application run failed

 

 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.context.annotation.internalConfigurationAnnotationProcessor': Failed to instantiate [org.springframework.context.annotation.ConfigurationClassPostProcessor]: No default constructor found

 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1314) ~[net.keepsoft.deploypoolscheduler.DpsApplication:6.0.9]

 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1199) ~[net.keepsoft.deploypoolscheduler.DpsApplication:6.0.9]

 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:560) ~[net.keepsoft.deploypoolscheduler.DpsApplication:6.0.9]

 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:520) ~[net.keepsoft.deploypoolscheduler.DpsApplication:6.0.9]

 	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[net.keepsoft.deploypoolscheduler.DpsApplication:6.0.9]

 	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[net.keepsoft.deploypoolscheduler.DpsApplication:6.0.9]

 	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[net.keepsoft.deploypoolscheduler.DpsApplication:6.0.9]

 	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:205) ~[net.keepsoft.deploypoolscheduler.DpsApplication:6.0.9]

 	at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:138) ~[na:na]

 	at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:771) ~[net.keepsoft.deploypoolscheduler.DpsApplication:6.0.9]

 	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:589) ~[net.keepsoft.deploypoolscheduler.DpsApplication:6.0.9]

 	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[net.keepsoft.deploypoolscheduler.DpsApplication:3.1.0]

 	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:733) ~[net.keepsoft.deploypoolscheduler.DpsApplication:3.1.0]

 	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:435) ~[net.keepsoft.deploypoolscheduler.DpsApplication:3.1.0]

 	at org.springframework.boot.SpringApplication.run(SpringApplication.java:311) ~[net.keepsoft.deploypoolscheduler.DpsApplication:3.1.0]

 	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1305) ~[net.keepsoft.deploypoolscheduler.DpsApplication:3.1.0]

 	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1294) ~[net.keepsoft.deploypoolscheduler.DpsApplication:3.1.0]

 	at net.keepsoft.deploypoolscheduler.DpsApplication.main(DpsApplication.java:17) ~[net.keepsoft.deploypoolscheduler.DpsApplication:na]

 Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.context.annotation.ConfigurationClassPostProcessor]: No default constructor found

 	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:83) ~[net.keepsoft.deploypoolscheduler.DpsApplication:6.0.9]

 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1308) ~[net.keepsoft.deploypoolscheduler.DpsApplication:6.0.9]

 	... 17 common frames omitted

 Caused by: java.lang.NoSuchMethodException: org.springframework.context.annotation.ConfigurationClassPostProcessor.<init>()

 	at java.base@17.0.7/java.lang.Class.getConstructor0(DynamicHub.java:3585) ~[net.keepsoft.deploypoolscheduler.DpsApplication:na]

 	at java.base@17.0.7/java.lang.Class.getDeclaredConstructor(DynamicHub.java:2754) ~[net.keepsoft.deploypoolscheduler.DpsApplication:na]

 	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:79) ~[net.keepsoft.deploypoolscheduler.DpsApplication:6.0.9]

 	... 18 common frames omitted

这里还是Mybatis的问题,在src\main\resources\META-INF\native-image\org.springframework\spring-context\6.0.10添加reflect-config.json,文件内容:

[{
  "name": "org.springframework.context.annotation.ConfigurationClassPostProcessor",
  "allDeclaredFields": true,
  "allDeclaredConstructors": true,
  "allDeclaredMethods": true,
  "allPublicMethods": true,
  "allDeclaredClasses": true
},{
  "name": "org.springframework.context.annotation.AnnotationScopeMetadataResolver",
  "allDeclaredFields": true,
  "allDeclaredConstructors": true,
  "allDeclaredMethods": true,
  "allPublicMethods": true,
  "allDeclaredClasses": true
}]

我以为我只要把这些找不到的包,补齐了就行了,以为最多就是费点时间的事儿。事实证明我还是太年轻了。

通过了近一天的查漏补缺,并且为了提升效率,又把打包环境从linux(单次打包10分钟)换到windows(单次打包2分钟)折腾之后,终于运行时不是报class not found了。而是...

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v3.1.1)

2023-07-06T15:29:16.131+08:00  INFO 2424 --- [           main] n.k.d.server.DemoApplication             : Starting AOT-processed DemoApplication using Java 17.0.7 with PID 2424 (D:\github\spring-native-demo\target\demo.exe started by Administrator in D:\github\spring-native-demo)
2023-07-06T15:29:16.131+08:00  INFO 2424 --- [           main] n.k.d.server.DemoApplication             : No active profile set, falling back to 1 default profile: "default"
2023-07-06T15:29:16.133+08:00  WARN 2424 --- [           main] o.m.s.mapper.ClassPathMapperScanner      : No MyBatis mapper was found in '[net.keepsoft.deploypoolscheduler.server]' package. Please check your configuration.

[ [ SubstrateSegfaultHandler caught a segfault in thread 0x000002075fee2c40 ] ]
siginfo: ExceptionCode: -1073741819, reading address 0xffffffffffffffff
Current timestamp: 1688628556138

General purpose register values:
  RAX 0x000002076386b3c8 points into the image heap (read-only huge)
  RBX 0x0000000000000001 is an unknown value
  RCX 0xfffffffffffffff8 is an unknown value
  RDX 0x3bcfe3113bcfd711 is an unknown value
  RBP 0x0000000000000000
  RSI 0x0000000000fd2648 is an unknown value
  RDI 0x0000000000000000
  RSP 0x000000930f52ee00 points into the stack for thread 0x000002075fee2c40
  R8  0x3bcfe5189d5fd711 is an unknown value
  R9  0x00000207629c9798 points into the image heap (read-only relocatables)
    is the hub of org.springframework.boot.autoconfigure.web.servlet.ServletWebServerFactoryConfiguration$EmbeddedJetty
  R10 0x0000020764d05ee0 points into an aligned TLAB chunk of thread 0x000002075fee2c40
    is an object of type java.util.LinkedHashMap
  R11 0x0000020764d05ae8 points into an aligned TLAB chunk of thread 0x000002075fee2c40
    is an object of type jdk.internal.reflect.ConstantPool
  R12 0x00000207629c9798 points into the image heap (read-only relocatables)
    is the hub of org.springframework.boot.autoconfigure.web.servlet.ServletWebServerFactoryConfiguration$EmbeddedJetty
  R13 0x0000020761900000 is the heap base
  R14 0x0000020761900000 is the heap base
  R15 0x000002075fee2c40 is a thread
  EFL 0x0000000000010206 is an unknown value
  RIP 0x00007ff7e33b24b6 points into AOT compiled code

Printing Instructions (ip=0x00007ff7e33b24b6):
  0x00007ff7e33b2496: 0x38 0x14 0xff 0x90 0x48 0x8b 0x14 0x05 0x00 0x00 0x00 0x00 0x4d 0x8d 0x04 0x16
  0x00007ff7e33b24a6: 0x48 0x85 0xd2 0x0f 0x84 0x1e 0x00 0x00 0x00 0x48 0xc7 0xc1 0xf8 0xff 0xff 0xff
  0x00007ff7e33b24b6: 0x49 0x23 0x0c 0x16 0x48 0xba 0x48 0x26 0xfd 0x00 0x00 0x00 0x00 0x00 0x48 0x3b
  0x00007ff7e33b24c6: 0xd1 0x0f 0x85 0x21 0x00 0x00 0x00 0x41 0x83 0x6f 0x10 0x01 0x0f 0x8e 0x08 0x00

Top of stack (sp=0x000000930f52ee00):
  0x000000930f52ee00: 0x0000020764d05a88 0x00007ff7e4476499
  0x000000930f52ee10: 0x0000020764d064b8 0x00000207622dd6f0
  0x000000930f52ee20: 0x0000020764d05ee0 0x0000020764b42060
  0x000000930f52ee30: 0x0000000000b6af88 0x0000000000000000
  0x000000930f52ee40: 0x357d22b000000001 0x0000020761900000
  0x000000930f52ee50: 0x00000207629c9798 0x0000020764d05ae8
  0x000000930f52ee60: 0x0000020764d05b00 0x00000207622dd6f0
  0x000000930f52ee70: 0x0000000064d064b8 0x00007ff7e447768d
  0x000000930f52ee80: 0x0000020764b4fad8 0x00007ff7e3063656
  0x000000930f52ee90: 0x00000207622dd6f0 0x000002076232e460
  0x000000930f52eea0: 0x0000020764d064b8 0x0000020764d05ee0
  0x000000930f52eeb0: 0x0000020764d05ee0 0x0000020764d05b00
  0x000000930f52eec0: 0x0000020761900000 0x00000207629c9798
  0x000000930f52eed0: 0x0000020764d05ae8 0x00000002e3ade916
  0x000000930f52eee0: 0x0000000300000002 0x00007ff7e447714f
  0x000000930f52eef0: 0x00000207629c9888 0x00000207631e1b60
  0x000000930f52ef00: 0xa76d7a706353b3c8 0x00007ff7e2c8bd7b
  0x000000930f52ef10: 0x00000207642aeeb0 0x00000207642824e0
  0x000000930f52ef20: 0x0000020762613a28 0x00000207631e1b60
  0x000000930f52ef30: 0x000012a200002544 0x00007ff7e3add760
  0x000000930f52ef40: 0x00000207642aedd8 0x00000207629c9798
  0x000000930f52ef50: 0x00000207634ea820 0x0000020764b4ff70
  0x000000930f52ef60: 0x00000207631e1b60 0x00007ff7e2591b8d
  0x000000930f52ef70: 0x0000000000b6af88 0x0000020762613a28
  0x000000930f52ef80: 0x0000000062f10ac8 0x00007ff7e2c8abb9
  0x000000930f52ef90: 0x00000207631952c8 0x0000020764d05980
  0x000000930f52efa0: 0x0000000000000000 0x0000020761900000
  0x000000930f52efb0: 0x00000000017e5950 0x00000207629c9798
  0x000000930f52efc0: 0x0000000062613a28 0x00007ff7e2c8e9d3
  0x000000930f52efd0: 0x0000020764d05950 0x00007ff7e3eb6472
  0x000000930f52efe0: 0x0000000000f13478 0x0000020764d054b8
  0x000000930f52eff0: 0x0000020762613a28 0x000002076353b2a8

Top frame info:
  TotalFrameSize in CodeInfoTable 16

Threads:
  0x000002075fee3640 STATUS_IN_NATIVE (ALLOW_SAFEPOINT) "Signal Dispatcher" - 0x0000020762e991b8, daemon, stack(0x000000930fc00000,0x000000930fd00000)
  0x000002075fee5700 STATUS_IN_NATIVE (ALLOW_SAFEPOINT) "Reference Handler" - 0x0000020762e98fa8, daemon, stack(0x000000930fb00000,0x000000930fc00000)
  0x000002075fee2c40 STATUS_IN_JAVA (PREVENT_VM_FROM_REACHING_SAFEPOINT) "main" - 0x0000020762e98ef8, stack(0x000000930f430000,0x000000930f530000)

VM thread locals for the failing thread 0x000002075fee2c40:
  0 (8 bytes): JNIThreadLocalEnvironment.jniFunctions = (bytes)
    0x000002075fee2c40: 0x00000207627e8610
  8 (8 bytes): StackOverflowCheckImpl.stackBoundaryTL = (Word) 1 (0x0000000000000001)
  16 (4 bytes): Safepoint.safepointRequested = (int) 2144832857 (0x7fd78d59)
  20 (4 bytes): StatusSupport.statusTL = (int) 1 (0x00000001)
  24 (32 bytes): ThreadLocalAllocation.regularTLAB = (bytes)
    0x000002075fee2c58: 0x0000020764d00000 0x0000020764e00000
    0x000002075fee2c68: 0x0000020764d06518 0x0000000000000000
  56 (8 bytes): PlatformThreads.currentThread = (Object) java.lang.Thread (0x0000020762e98ef8)
  64 (8 bytes): JavaFrameAnchors.lastAnchor = (Word) 0 (0x0000000000000000)
  72 (8 bytes): AccessControlContextStack = (Object) java.util.ArrayDeque (0x00000207642116a8)
  80 (8 bytes): ExceptionUnwind.currentException = (Object) null
  88 (8 bytes): IdentityHashCodeSupport.hashCodeGeneratorTL = (Object) java.util.SplittableRandom (0x0000020764292b98)
  96 (8 bytes): IsolatedCompileClient.currentClient = (Object) null
  104 (8 bytes): IsolatedCompileContext.currentContext = (Object) null
  112 (8 bytes): JNIObjectHandles.handles = (Object) com.oracle.svm.core.handles.ThreadLocalHandles (0x00000207642011a0)
  120 (8 bytes): JNIThreadLocalPendingException.pendingException = (Object) null
  128 (8 bytes): JNIThreadLocalPinnedObjects.pinnedObjectsListHead = (Object) null
  136 (8 bytes): JNIThreadOwnedMonitors.ownedMonitors = (Object) null
  144 (8 bytes): NoAllocationVerifier.openVerifiers = (Object) null
  152 (8 bytes): ThreadingSupportImpl.activeTimer = (Object) null
  160 (8 bytes): SubstrateDiagnostics.threadOnlyAttachedForCrashHandler = (bytes)
    0x000002075fee2ce0: 0x0000000000000000
  168 (8 bytes): ThreadLocalAllocation.allocatedBytes = (Word) 11488440 (0x0000000000af4cb8)
  176 (8 bytes): VMThreads.IsolateTL = (Word) 2230724853760 (0x0000020761900000)
  184 (8 bytes): VMThreads.OSThreadHandleTL = (Word) 328 (0x0000000000000148)
  192 (8 bytes): VMThreads.OSThreadIdTL = (Word) 21664 (0x00000000000054a0)
  200 (8 bytes): VMThreads.StackBase = (Word) 631617290240 (0x000000930f530000)
  208 (8 bytes): VMThreads.StackEnd = (Word) 631616241664 (0x000000930f430000)
  216 (8 bytes): VMThreads.StartedByCurrentIsolate = (bytes)
    0x000002075fee2d18: 0x0000000000000000
  224 (8 bytes): VMThreads.nextTL = (Word) 0 (0x0000000000000000)
  232 (8 bytes): VMThreads.unalignedIsolateThreadMemoryTL = (Word) 2230697471008 (0x000002075fee2c20)
  240 (4 bytes): ActionOnExitSafepointSupport.actionTL = (int) 0 (0x00000000)
  244 (4 bytes): ActionOnTransitionToJavaSupport.actionTL = (int) 0 (0x00000000)
  248 (4 bytes): ImplicitExceptions.implicitExceptionsAreFatal = (int) 0 (0x00000000)
  252 (4 bytes): StackOverflowCheckImpl.yellowZoneStateTL = (int) 2130640638 (0x7efefefe)
  256 (4 bytes): StatusSupport.safepointBehaviorTL = (int) 1 (0x00000001)
  260 (4 bytes): ThreadingSupportImpl.currentPauseDepth = (int) 0 (0x00000000)

No VMOperation in progress

The 15 most recent VM operation status changes (oldest first):

Counters:

Java frame anchors for the failing thread 0x000002075fee2c40:
  No anchors

Stacktrace for the failing thread 0x000002075fee2c40:
  SP 0x000000930f52ee00 IP 0x00007ff7e33b24b6  com.oracle.svm.core.code.CodeInfo@0x20762d0ee00 name = image code
  SP 0x000000930f52ee10 IP 0x00007ff7e4476499  [image code] sun.reflect.annotation.AnnotationParser.parseAnnotation2(AnnotationParser.java:70)
  SP 0x000000930f52ee80 IP 0x00007ff7e447768d  [image code] sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:121)
  SP 0x000000930f52eef0 IP 0x00007ff7e447714f  [image code] sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:73)
  SP 0x000000930f52ef10 IP 0x00007ff7e2c8bd7b  [image code] java.lang.Class.createAnnotationData(DynamicHub.java:4068)
  SP 0x000000930f52ef90 IP 0x00007ff7e2c8abb9  [image code] java.lang.Class.annotationData(DynamicHub.java:4057)
  SP 0x000000930f52efd0 IP 0x00007ff7e2c8e9d3  [image code] java.lang.Class.getDeclaredAnnotations(DynamicHub.java:4024)
  SP 0x000000930f52efe0 IP 0x00007ff7e3eb6472  [image code] org.springframework.context.annotation.ConfigurationClassParser.asSourceClass(ConfigurationClassParser.java:572)
  SP 0x000000930f52f020 IP 0x00007ff7e3eb43f5  [image code] org.springframework.context.annotation.ConfigurationClassParser$SourceClass.getRelated(ConfigurationClassParser.java:991)
  SP 0x000000930f52f060 IP 0x00007ff7e3eb2792  [image code] org.springframework.context.annotation.ConfigurationClassParser$SourceClass.getAnnotationAttributes(ConfigurationClassParser.java:982)
  SP 0x000000930f52f0a0 IP 0x00007ff7e3eb7415  [image code] org.springframework.context.annotation.ConfigurationClassParser.collectImports(ConfigurationClassParser.java:463)
  SP 0x000000930f52f100 IP 0x00007ff7e3eb8ec8  [image code] org.springframework.context.annotation.ConfigurationClassParser.getImports(ConfigurationClassParser.java:436)
  SP 0x000000930f52f140 IP 0x00007ff7e3eb79eb  [image code] org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:304)
  SP 0x000000930f52f200 IP 0x00007ff7e3eba5da  [image code] org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:243)
  SP 0x000000930f52f240 IP 0x00007ff7e3eba0d2  [image code] org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:192)
  SP 0x000000930f52f270 IP 0x00007ff7e3eb9744  [image code] org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:167)
  SP 0x000000930f52f2c0 IP 0x00007ff7e3ec5ed3  [image code] org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:415)
  SP 0x000000930f52f410 IP 0x00007ff7e3ec382c  [image code] org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:287)
  SP 0x000000930f52f460 IP 0x00007ff7e3efe36c  [image code] org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:344)
  SP 0x000000930f52f490 IP 0x00007ff7e3f00566  [image code] org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:145)
  SP 0x000000930f52f5c0 IP 0x00007ff7e3ef0b0a  [image code] org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:771)
  SP 0x000000930f52f5c0 IP 0x00007ff7e3ef0b0a  [image code] org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:589)
  SP 0x000000930f52f630 IP 0x00007ff7e3e659bb  [image code] org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146)
  SP 0x000000930f52f650 IP 0x00007ff7e3c9294f  [image code] org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734)
  SP 0x000000930f52f650 IP 0x00007ff7e3c9294f  [image code] org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:436)
  SP 0x000000930f52f670 IP 0x00007ff7e3c92fdb  [image code] org.springframework.boot.SpringApplication.run(SpringApplication.java:312)
  SP 0x000000930f52f720 IP 0x00007ff7e3c93bd0  [image code] org.springframework.boot.SpringApplication.run(SpringApplication.java:1306)
  SP 0x000000930f52f740 IP 0x00007ff7e3560648  [image code] org.springframework.boot.SpringApplication.run(SpringApplication.java:1295)
  SP 0x000000930f52f740 IP 0x00007ff7e3560648  [image code] net.keepsoft.deploypoolscheduler.server.DemoApplication.main(DemoApplication.java:16)
  SP 0x000000930f52f780 IP 0x00007ff7e24e6557  [image code] com.oracle.svm.core.JavaMainWrapper.runCore0(JavaMainWrapper.java:182)
  SP 0x000000930f52f7b0 IP 0x00007ff7e24e61c3  [image code] com.oracle.svm.core.JavaMainWrapper.runCore(JavaMainWrapper.java:139)
  SP 0x000000930f52f7b0 IP 0x00007ff7e24e61c3  [image code] com.oracle.svm.core.JavaMainWrapper.doRun(JavaMainWrapper.java:261)
  SP 0x000000930f52f7f0 IP 0x00007ff7e255dba6  [image code] com.oracle.svm.core.JavaMainWrapper.run(JavaMainWrapper.java:247)
  SP 0x000000930f52f7f0 IP 0x00007ff7e255dba6  [image code] com.oracle.svm.core.code.IsolateEnterStub.JavaMainWrapper_run_3148eece06270530b6e0d4d60311411342c82698(IsolateEnterStub.java:0)

VM mutexes:
  mutex "referencePendingList" is unlocked.
  mutex "thread" is unlocked.
  mutex "mainVMOperationControlWorkQueue" is unlocked.

AOT compiled code is mapped at 0x00007ff7e1df1000 - 0x00007ff7e498f2bf

Heap settings and statistics:
  Supports isolates: true
  Heap base: 0x0000020761900000
  Object reference size: 8
  Aligned chunk size: 1048576
  Incremental collections: 0
  Complete collections: 0

Native image heap boundaries:
  ReadOnly Primitives: 0x0000020761a01028 - 0x000002076229e668
  ReadOnly References: 0x000002076229e668 - 0x00000207627e4de8
  ReadOnly Relocatables: 0x00000207627e5000 - 0x0000020762b96d00
  Writable Primitives: 0x0000020762b97000 - 0x0000020762d75688
  Writable References: 0x0000020762d75688 - 0x000002076355b628
  Writable Huge: 0x0000020763600030 - 0x0000020763748a50
  ReadOnly Huge: 0x0000020763749030 - 0x000002076418c608

Heap:
  Young generation:
    Eden:
      edenSpace:
        aligned: 0/0 unaligned: 0/0
    Survivors:
      Survivor-1 From:
        aligned: 0/0 unaligned: 0/0
      Survivor-1 To:
        aligned: 0/0 unaligned: 0/0
      Survivor-2 From:
        aligned: 0/0 unaligned: 0/0
      Survivor-2 To:
        aligned: 0/0 unaligned: 0/0
      Survivor-3 From:
        aligned: 0/0 unaligned: 0/0
      Survivor-3 To:
        aligned: 0/0 unaligned: 0/0
      Survivor-4 From:
        aligned: 0/0 unaligned: 0/0
      Survivor-4 To:
        aligned: 0/0 unaligned: 0/0
      Survivor-5 From:
        aligned: 0/0 unaligned: 0/0
      Survivor-5 To:
        aligned: 0/0 unaligned: 0/0
      Survivor-6 From:
        aligned: 0/0 unaligned: 0/0
      Survivor-6 To:
        aligned: 0/0 unaligned: 0/0
      Survivor-7 From:
        aligned: 0/0 unaligned: 0/0
      Survivor-7 To:
        aligned: 0/0 unaligned: 0/0
      Survivor-8 From:
        aligned: 0/0 unaligned: 0/0
      Survivor-8 To:
        aligned: 0/0 unaligned: 0/0
      Survivor-9 From:
        aligned: 0/0 unaligned: 0/0
      Survivor-9 To:
        aligned: 0/0 unaligned: 0/0
      Survivor-10 From:
        aligned: 0/0 unaligned: 0/0
      Survivor-10 To:
        aligned: 0/0 unaligned: 0/0
      Survivor-11 From:
        aligned: 0/0 unaligned: 0/0
      Survivor-11 To:
        aligned: 0/0 unaligned: 0/0
      Survivor-12 From:
        aligned: 0/0 unaligned: 0/0
      Survivor-12 To:
        aligned: 0/0 unaligned: 0/0
      Survivor-13 From:
        aligned: 0/0 unaligned: 0/0
      Survivor-13 To:
        aligned: 0/0 unaligned: 0/0
      Survivor-14 From:
        aligned: 0/0 unaligned: 0/0
      Survivor-14 To:
        aligned: 0/0 unaligned: 0/0
      Survivor-15 From:
        aligned: 0/0 unaligned: 0/0
      Survivor-15 To:
        aligned: 0/0 unaligned: 0/0
  Old generation:
    oldFromSpace:
      aligned: 0/0 unaligned: 0/0
    oldToSpace:
      aligned: 0/0 unaligned: 0/0

  Unused:
    aligned: 0/0

Segfault detected, aborting process. Use runtime option -R:-InstallSegfaultHandler if you don't want to use SubstrateSegfaultHandler.

好吧,解锁了一个新错误,

关于此错误,暂时还没找到啥资料,这坑看来暂时爬不出来了。

先记录到这里,看看后续能不能找到解决方案。

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 10
    评论
好的,你想了解 Spring Boot 中使用原生 SQL 进行分页查询的相关内容,是吗?那我来回答你的问题。 在 Spring Boot 中,使用原生 SQL 进行分页查询需要进行以下几个步骤: 1. 在 pom.xml 文件中添加相关依赖,例如 mysql-connector-java: ```xml <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.21</version> </dependency> ``` 2. 在 application.properties 文件中配置数据源信息,例如: ```properties spring.datasource.url=jdbc:mysql://localhost:3306/test spring.datasource.username=root spring.datasource.password=123456 spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver ``` 3. 在代码中使用原生 SQL 进行分页查询,例如: ```java @Autowired private JdbcTemplate jdbcTemplate; public Page<User> findPage(int pageNum, int pageSize) { String countSql = "SELECT COUNT(*) FROM user"; int totalCount = jdbcTemplate.queryForObject(countSql, Integer.class); int pageCount = totalCount / pageSize + (totalCount % pageSize == 0 ? 0 : 1); int startIndex = (pageNum - 1) * pageSize; String listSql = "SELECT * FROM user LIMIT ?, ?"; List<User> list = jdbcTemplate.query(listSql, new Object[]{startIndex, pageSize}, new BeanPropertyRowMapper<>(User.class)); return new Page<>(pageNum, pageSize, totalCount, pageCount, list); } ``` 以上代码中,我们使用了两个 SQL 语句,一个用于查询总记录数,另一个用于查询分页数据。在查询总记录数时,我们直接使用了 JdbcTemplate 的 queryForObject 方法,并将返回结果转换为 Integer 类型;在查询分页数据时,我们使用了 LIMIT 关键字来限制查询范围,并使用了 BeanPropertyRowMapper 将查询结果转换为 User 对象的列表。 最后,我们将分页查询结果封装为一个 Page 对象,并返回给调用者。 需要注意的是,上述代码中使用的是原生 SQL,需要根据实际情况进行 SQL 注入和 SQL 注解的处理。同时,在实际项目中,还需要进行参数校验,例如 pageNum 和 pageSize 是否合法、是否超出范围等。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 10
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值