diff --git a/frameworks/Java/tio-http-server/pom.xml b/frameworks/Java/tio-http-server/pom.xml
index 2b16997b60e..080b11956ff 100644
--- a/frameworks/Java/tio-http-server/pom.xml
+++ b/frameworks/Java/tio-http-server/pom.xml
@@ -16,12 +16,12 @@
com.litongjava
tio-http-server
- 3.7.3.v20240919-RELEASE
+ 3.7.3.v20250301-RELEASE
com.litongjava
java-db
- 1.2.6
+ 1.4.9
junit
@@ -31,16 +31,6 @@
-
-
-
-
com.alibaba.fastjson2
fastjson2
@@ -66,144 +56,67 @@
-
-
-
- development
-
- true
-
-
-
- ch.qos.logback
- logback-classic
- 1.2.13
-
-
-
+
+
+ central
+ Central Repository
+ https://repo.maven.apache.org/maven2
+
+
+ sonatype-nexus-snapshots
+ Sonatype Nexus Snapshots
+ https://oss.sonatype.org/content/repositories/snapshots
+
+
+
+
+ central
+ Central Repository
+ https://repo.maven.apache.org/maven2
+
+
+ sonatype-nexus-snapshots
+ Sonatype Nexus Snapshots
+ https://oss.sonatype.org/content/repositories/snapshots
+
+ false
+
+
+ true
+
+
+
+
+
+
+
+ true
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.8.0
+
+ false
+
+
-
-
- production
-
-
- ch.qos.logback
- logback-classic
- 1.2.13
-
-
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
- 2.7.4
-
- ${main.class}
- org.projectlombok
-
-
-
-
-
- repackage
-
-
-
-
-
-
-
-
-
- assembly
-
-
- ch.qos.logback
- logback-classic
- 1.2.13
-
-
-
-
-
- org.apache.maven.plugins
- maven-jar-plugin
- 3.2.0
-
-
- org.apache.maven.plugins
- maven-assembly-plugin
- 3.1.1
-
-
-
- ${main.class}
-
-
-
- jar-with-dependencies
-
- false
-
-
-
- make-assembly
- package
-
- single
-
-
-
-
-
-
-
-
- native
-
-
-
- org.slf4j
- slf4j-jdk14
- 1.7.31
-
-
-
- org.graalvm.sdk
- graal-sdk
- ${graalvm.version}
- provided
-
-
-
- ${project.artifactId}
-
-
- org.graalvm.nativeimage
- native-image-maven-plugin
- 21.2.0
-
-
-
- native-image
-
- package
-
-
-
- false
- ${project.artifactId}
- ${main.class}
-
- -H:+RemoveSaturatedTypeFlows
- --allow-incomplete-classpath
- --no-fallback
-
-
-
-
-
-
-
+
+ maven-assembly-plugin
+ 3.1.0
+
+
+ jar-with-dependencies
+
+
+
+
+ make-assembly
+ package
+
+ single
+
+
+
+
+
+
\ No newline at end of file
diff --git a/frameworks/Java/tio-http-server/src/main/java/com/litongjava/tio/http/server/MainApp.java b/frameworks/Java/tio-http-server/src/main/java/com/litongjava/tio/http/server/MainApp.java
index 43a6bfc5804..6de2f4cbedb 100644
--- a/frameworks/Java/tio-http-server/src/main/java/com/litongjava/tio/http/server/MainApp.java
+++ b/frameworks/Java/tio-http-server/src/main/java/com/litongjava/tio/http/server/MainApp.java
@@ -9,7 +9,7 @@
import com.litongjava.tio.http.server.controller.DbController;
import com.litongjava.tio.http.server.controller.IndexController;
import com.litongjava.tio.http.server.handler.DefaultHttpRequestDispatcher;
-import com.litongjava.tio.http.server.router.DefaultHttpReqeustRouter;
+import com.litongjava.tio.http.server.router.DefaultHttpRequestRouter;
import com.litongjava.tio.http.server.router.HttpRequestRouter;
import com.litongjava.tio.server.ServerTioConfig;
import com.litongjava.tio.utils.environment.EnvUtils;
@@ -18,11 +18,12 @@ public class MainApp {
public static void main(String[] args) {
long start = System.currentTimeMillis();
+ EnvUtils.buildCmdArgsMap(args);
EnvUtils.load();
// add route
IndexController controller = new IndexController();
- HttpRequestRouter simpleHttpRoutes = new DefaultHttpReqeustRouter();
+ HttpRequestRouter simpleHttpRoutes = new DefaultHttpRequestRouter();
simpleHttpRoutes.add("/", controller::index);
simpleHttpRoutes.add("/plaintext", controller::plaintext);
simpleHttpRoutes.add("/json", controller::json);
@@ -49,9 +50,16 @@ public static void main(String[] args) {
// close Heartbeat
serverTioConfig.setHeartbeatTimeout(0);
serverTioConfig.statOn = false;
+ boolean db = EnvUtils.getBoolean("db", true);
+ if (db) {
+ try {
+ new MysqlDbConfig().init();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
// start server
try {
- new MysqlDbConfig().init();
new EnjoyEngineConfig().engine();
new EhCachePluginConfig().ehCachePlugin();
httpServerStarter.start();
diff --git a/frameworks/Java/tio-http-server/src/main/java/com/litongjava/tio/http/server/controller/CacheController.java b/frameworks/Java/tio-http-server/src/main/java/com/litongjava/tio/http/server/controller/CacheController.java
index 6ecd7664ac1..ef48b3990db 100644
--- a/frameworks/Java/tio-http-server/src/main/java/com/litongjava/tio/http/server/controller/CacheController.java
+++ b/frameworks/Java/tio-http-server/src/main/java/com/litongjava/tio/http/server/controller/CacheController.java
@@ -7,7 +7,7 @@
import com.alibaba.fastjson2.JSON;
import com.litongjava.db.activerecord.Db;
-import com.litongjava.db.activerecord.Record;
+import com.litongjava.db.activerecord.Row;
import com.litongjava.tio.http.common.HeaderName;
import com.litongjava.tio.http.common.HeaderValue;
import com.litongjava.tio.http.common.HttpRequest;
@@ -24,7 +24,7 @@ public HttpResponse cachedQuery(HttpRequest request) {
.limit(RandomUtils.parseQueryCount(queries)) // 限制查询数量
.mapToObj(id -> findByIdWithCache("world", id)) // 使用 mapToObj 将 int 映射为对象
.filter(Objects::nonNull) // 过滤掉 null 值
- .map(Record::toMap) // 将每个 Record 对象转换为 Map
+ .map(Row::toMap) // 将每个 Record 对象转换为 Map
.collect(Collectors.toList()); // 收集到 List
HttpResponse httpResponse = new HttpResponse(request);
@@ -34,7 +34,7 @@ public HttpResponse cachedQuery(HttpRequest request) {
}
- private Record findByIdWithCache(String tableName, int id) {
+ private Row findByIdWithCache(String tableName, int id) {
String sql = "SELECT id, randomNumber FROM world WHERE id = ?";
return Db.findFirstByCache(tableName, id, sql, id);
}
diff --git a/frameworks/Java/tio-http-server/src/main/java/com/litongjava/tio/http/server/controller/DbController.java b/frameworks/Java/tio-http-server/src/main/java/com/litongjava/tio/http/server/controller/DbController.java
index 699b313bd69..782543a81e0 100644
--- a/frameworks/Java/tio-http-server/src/main/java/com/litongjava/tio/http/server/controller/DbController.java
+++ b/frameworks/Java/tio-http-server/src/main/java/com/litongjava/tio/http/server/controller/DbController.java
@@ -12,15 +12,14 @@
import com.jfinal.template.Engine;
import com.jfinal.template.Template;
import com.litongjava.db.activerecord.Db;
-import com.litongjava.db.activerecord.Record;
-import com.litongjava.ehcache.EhCache;
+import com.litongjava.db.activerecord.Row;
+import com.litongjava.ehcache.EhCacheKit;
import com.litongjava.tio.http.common.HeaderName;
import com.litongjava.tio.http.common.HeaderValue;
import com.litongjava.tio.http.common.HttpRequest;
import com.litongjava.tio.http.common.HttpResponse;
import com.litongjava.tio.http.server.model.Fortune;
import com.litongjava.tio.http.server.util.Resps;
-import com.litongjava.tio.http.server.utils.BeanConverterUtils;
import com.litongjava.tio.http.server.utils.RandomUtils;
public class DbController {
@@ -37,7 +36,7 @@ public HttpResponse db(HttpRequest request) {
// int id = 11;
// String sql="SELECT id, randomNumber FROM world WHERE id = ?";
- Record recored = Db.findById("world", id);
+ Row recored = Db.findById("world", id);
if (recored != null) {
httpResponse.setBody(JSON.toJSONBytes(recored.toMap()));
} else {
@@ -57,7 +56,7 @@ public HttpResponse queries(HttpRequest request) {
.limit(RandomUtils.parseQueryCount(queries)) // 限制查询数量
.mapToObj(id -> Db.findById("world", id)) // 使用 mapToObj 将 int 映射为对象
.filter(Objects::nonNull) // 过滤掉 null 值
- .map(Record::toMap) // 将每个 Record 对象转换为 Map
+ .map(Row::toMap) // 将每个 Record 对象转换为 Map
.collect(Collectors.toList()); // 收集到 List
HttpResponse httpResponse = new HttpResponse(request);
@@ -66,11 +65,11 @@ public HttpResponse queries(HttpRequest request) {
return httpResponse;
}
-//@GetMapping("/updates")
+ //@GetMapping("/updates")
public HttpResponse updates(HttpRequest request) {
String queries = request.getParam("queries");
- EhCache.removeAll("world");
+ EhCacheKit.removeAll("world");
List