使用:com.github.pagehelper
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>5.2.0</version>
</dependency>
<dependency>
MyBatisResource.java
@Path("/user/{id}")
@GET
@Produces(MediaType.APPLICATION_JSON)
public List<Users> getUser(@PathParam("id") Integer id) {
Page<Users> page = PageHelper.startPage(1, 2);
List<Users> list = usersMapper.selectByExample(null);
System.out.println(list.size());
System.out.println(page.getResult().size());
return page.getResult();
}
pom.xml
<properties>
<quarkus.package.type>native</quarkus.package.type>
<quarkus.native.additional-build-args>
--report-unsupported-elements-at-runtime,
-H:DynamicProxyConfigurationResources=proxy.json,
-H:ReflectionConfigurationFiles=reflection-config.json
</quarkus.native.additional-build-args>
</properties>
src/main/resources/proxy.json
[
["org.apache.ibatis.executor.Executor","com.github.pagehelper.Dialect"]
]
src/main/resources/reflection-config.json
[
{
"name" : "com.github.pagehelper.PageInterceptor",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"allDeclaredFields" : true,
"allPublicFields" : true
},{
"name" : "org.apache.ibatis.executor.Executor",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"allDeclaredFields" : true,
"allPublicFields" : true
},
{
"name" : "org.apache.ibatis.session.SqlSession",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"allDeclaredFields" : true,
"allPublicFields" : true
},
{
"name" : "org.apache.ibatis.session.SqlSessionManager",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"allDeclaredFields" : true,
"allPublicFields" : true
},
{
"name" : "com.github.pagehelper.Dialect",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"allDeclaredFields" : true,
"allPublicFields" : true
},
{
"name" : "com.github.pagehelper.Dialect",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"allDeclaredFields" : true,
"allPublicFields" : true
},
{
"name" : "com.github.pagehelper.page.PageAutoDialect",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"allDeclaredFields" : true,
"allPublicFields" : true
},
{
"name" : "org.apache.ibatis.mapping.BoundSql",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"allDeclaredFields" : true,
"allPublicFields" : true,
"fields" : [ { "name" : "parameterMappings", "allowWrite" : true },
{ "name" : "sql", "allowWrite" : true },
{ "name" : "parameterObject", "allowWrite" : true },
{ "name" : "additionalParameters", "allowWrite" : true },
{ "name" : "metaParameters", "allowWrite" : true }]
}
]
mvn clean package -DskipTests -Pnative(比较消耗资源和时间)
-g -H:DebugInfoSourceSearchPath=app-sources -H:+AddAllCharsets -H:EnableURLProtocols=http,https --enable-all-security-services -H:NativeLinkerOption=-no-pie --no-server -H:-UseServiceLoaderFeature -H:+StackTrace mybatis-quickstart-1.0.0-SNAPSHOT-runner
[mybatis-quickstart-1.0.0-SNAPSHOT-runner:54623] classlist: 8,320.30 ms, 1.19 GB
[mybatis-quickstart-1.0.0-SNAPSHOT-runner:54623] (cap): 779.76 ms, 1.19 GB
[mybatis-quickstart-1.0.0-SNAPSHOT-runner:54623] setup: 3,986.16 ms, 1.19 GB
17:29:52,934 INFO [org.jbo.threads] JBoss Threads version 3.2.0.Final
[mybatis-quickstart-1.0.0-SNAPSHOT-runner:54623] (clinit): 1,234.71 ms, 4.72 GB
[mybatis-quickstart-1.0.0-SNAPSHOT-runner:54623] (typeflow): 48,894.26 ms, 4.72 GB
[mybatis-quickstart-1.0.0-SNAPSHOT-runner:54623] (objects): 55,627.95 ms, 4.72 GB
[mybatis-quickstart-1.0.0-SNAPSHOT-runner:54623] (features): 2,156.42 ms, 4.72 GB
[mybatis-quickstart-1.0.0-SNAPSHOT-runner:54623] analysis: 110,393.06 ms, 4.72 GB
[mybatis-quickstart-1.0.0-SNAPSHOT-runner:54623] universe: 3,695.19 ms, 4.72 GB
[mybatis-quickstart-1.0.0-SNAPSHOT-runner:54623] (parse): 32,761.78 ms, 6.35 GB
[mybatis-quickstart-1.0.0-SNAPSHOT-runner:54623] (inline): 23,920.26 ms, 7.01 GB
[mybatis-quickstart-1.0.0-SNAPSHOT-runner:54623] (compile): 96,217.59 ms, 6.48 GB
[mybatis-quickstart-1.0.0-SNAPSHOT-runner:54623] compile: 157,009.47 ms, 6.48 GB
[mybatis-quickstart-1.0.0-SNAPSHOT-runner:54623] dbginfo: 38,128.74 ms, 6.57 GB
[mybatis-quickstart-1.0.0-SNAPSHOT-runner:54623] image: 49,596.37 ms, 6.57 GB
[mybatis-quickstart-1.0.0-SNAPSHOT-runner:54623] write: 3,655.74 ms, 6.56 GB
# Printing build artifacts to: mybatis-quickstart-1.0.0-SNAPSHOT-runner.build_artifacts.txt
[mybatis-quickstart-1.0.0-SNAPSHOT-runner:54623] [total]: 337,229.13 ms, 6.56 GB
[INFO] [io.quarkus.deployment.QuarkusAugmentor] Quarkus augmentation completed in 344563ms
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 05:50 min
[INFO] Finished at: 2021-05-28T17:34:46+08:00
[INFO] ------------------------------------------------------------------------
启动:./target/mybatis-quickstart-1.0.0-SNAPSHOT-runner
--/ __ \/ / / / _ | / _ \/ //_/ / / / __/
-/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/
2021-05-28 17:35:38,004 DEBUG [com.arj.ats.jta] (main) Setting up node identifiers '[quarkus]' for which recovery will be performed
2021-05-28 17:35:38,005 DEBUG [io.qua.agr.run.DataSources] (main) Started datasource aa connected to jdbc:mysql://localhost:3306/test
2021-05-28 17:35:38,005 DEBUG [io.qua.ver.cor.run.VertxCoreRecorder] (main) Vert.x Cache configured to: /tmp/vertx-cache/8719528319091654300
2021-05-28 17:35:38,006 DEBUG [io.qua.ver.cor.run.VertxCoreRecorder] (main) Vertx has Native Transport Enabled: false
2021-05-28 17:35:38,007 DEBUG [io.net.buf.PooledByteBufAllocator] (vert.x-eventloop-thread-2) -Dio.netty.allocator.numHeapArenas: 8
2021-05-28 17:35:38,007 DEBUG [io.net.buf.PooledByteBufAllocator] (vert.x-eventloop-thread-2) -Dio.netty.allocator.numDirectArenas: 8
2021-05-28 17:35:38,007 DEBUG [io.net.buf.PooledByteBufAllocator] (vert.x-eventloop-thread-2) -Dio.netty.allocator.pageSize: 8192
2021-05-28 17:35:38,007 DEBUG [io.net.buf.PooledByteBufAllocator] (vert.x-eventloop-thread-2) -Dio.netty.allocator.maxOrder: 1
2021-05-28 17:35:38,007 DEBUG [io.net.buf.PooledByteBufAllocator] (vert.x-eventloop-thread-2) -Dio.netty.allocator.chunkSize: 16384
2021-05-28 17:35:38,007 DEBUG [io.net.buf.PooledByteBufAllocator] (vert.x-eventloop-thread-2) -Dio.netty.allocator.tinyCacheSize: 512
2021-05-28 17:35:38,007 DEBUG [io.net.buf.PooledByteBufAllocator] (vert.x-eventloop-thread-2) -Dio.netty.allocator.smallCacheSize: 256
2021-05-28 17:35:38,007 DEBUG [io.net.buf.PooledByteBufAllocator] (vert.x-eventloop-thread-2) -Dio.netty.allocator.normalCacheSize: 64
2021-05-28 17:35:38,007 DEBUG [io.net.buf.PooledByteBufAllocator] (vert.x-eventloop-thread-2) -Dio.netty.allocator.maxCachedBufferCapacity: 32768
2021-05-28 17:35:38,008 DEBUG [io.net.buf.PooledByteBufAllocator] (vert.x-eventloop-thread-2) -Dio.netty.allocator.cacheTrimInterval: 8192
2021-05-28 17:35:38,008 DEBUG [io.net.buf.PooledByteBufAllocator] (vert.x-eventloop-thread-2) -Dio.netty.allocator.cacheTrimIntervalMillis: 0
2021-05-28 17:35:38,008 DEBUG [io.net.buf.PooledByteBufAllocator] (vert.x-eventloop-thread-2) -Dio.netty.allocator.useCacheForAllThreads: true
2021-05-28 17:35:38,008 DEBUG [io.net.buf.PooledByteBufAllocator] (vert.x-eventloop-thread-2) -Dio.netty.allocator.maxCachedByteBuffersPerChunk: 1023
2021-05-28 17:35:38,008 DEBUG [io.net.buf.ByteBufUtil] (vert.x-eventloop-thread-2) -Dio.netty.allocator.type: pooled
2021-05-28 17:35:38,008 DEBUG [io.net.buf.ByteBufUtil] (vert.x-eventloop-thread-2) -Dio.netty.threadLocalDirectBufferSize: 0
2021-05-28 17:35:38,008 DEBUG [io.net.buf.ByteBufUtil] (vert.x-eventloop-thread-2) -Dio.netty.maxThreadLocalCharBufferSize: 16384
2021-05-28 17:35:38,010 INFO [io.quarkus] (main) mybatis-quickstart 1.0.0-SNAPSHOT native (powered by Quarkus 1.13.3.Final) started in 0.019s. Listening on: http://0.0.0.0:8080
2021-05-28 17:35:38,010 INFO [io.quarkus] (main) Profile prod activated.
2021-05-28 17:35:38,010 INFO [io.quarkus] (main) Installed features: [agroal, cdi, jdbc-mysql, mutiny, mybatis, narayana-jta, resteasy, resteasy-jackson, smallrye-context-propagation, smallrye-openapi]
2021-05-28 17:45:00,301 DEBUG [org.apa.iba.tra.jdb.JdbcTransaction] (executor-thread-1) Opening JDBC Connection
2021-05-28 17:45:00,301 DEBUG [org.apa.iba.tra.jdb.JdbcTransaction] (executor-thread-1) Setting autocommit to false on JDBC Connection [wrapped[com.mysql.cj.jdbc.ConnectionImpl@1357e63b]]
2021-05-28 17:45:00,301 DEBUG [com.ai.tes.Use.selectByExample_COUNT] (executor-thread-1) ==> Preparing: SELECT count(0) FROM users
2021-05-28 17:45:00,302 DEBUG [com.ai.tes.Use.selectByExample_COUNT] (executor-thread-1) ==> Parameters:
2021-05-28 17:45:00,303 DEBUG [com.ai.tes.Use.selectByExample_COUNT] (executor-thread-1) <== Total: 1
2021-05-28 17:45:00,303 DEBUG [com.ai.tes.Use.selectByExample] (executor-thread-1) ==> Preparing: select 'false' as QUERYID, id,name from users LIMIT ?
2021-05-28 17:45:00,303 DEBUG [com.ai.tes.Use.selectByExample] (executor-thread-1) ==> Parameters: 2(Integer)
2021-05-28 17:45:00,304 DEBUG [com.ai.tes.Use.selectByExample] (executor-thread-1) <== Total: 2
2021-05-28 17:45:00,304 DEBUG [org.apa.iba.tra.jdb.JdbcTransaction] (executor-thread-1) Resetting autocommit to true on JDBC Connection [wrapped[com.mysql.cj.jdbc.ConnectionImpl@1357e63b]]
2021-05-28 17:45:00,304 DEBUG [org.apa.iba.tra.jdb.JdbcTransaction] (executor-thread-1) Closing JDBC Connection [wrapped[com.mysql.cj.jdbc.ConnectionImpl@1357e63b]]