2025-09-08 12:37

加个 handler 或者全局拦截器,例如:
public class MyHandler extends Handler {
public void handle(....) {
String method = request.getMethod();
if (method.equals("TRACE") || method.equals("TRACK) {
HandlerKit.renderError404(..);
} else {
next.handle(...);
}
}

2025-09-06 11:28

@北流家园网 热加载的 class load 不同, 获取 class loader 这个会吧?

if (Thread.currentThread().getContextClassLoader().getClass() == HotSwapClassLoader.class) {
热加载模式之下
} else {
...
}

2025-09-06 01:06

@北流家园网 简单来说就是新增一个 /etc/systemd/system/your_project.service

在这个 your_project.service 文件中添加依赖,例如下面是添加了对 mysql 的依赖:
[Unit]
Description=MyApp Service
After=network.target mysqld.service
Requires=mysqld.service

# 其它部分省略

以上的 After、Requires 会让你的应用在 mysql 启动之后再启动。

这个 xxx.service 脚本写完后还要通过 systemctl 让它生效,然后就可以通过如下的方法启动、停止、重启项目了:

systemctl start xxx
systemctl stop xxx
systemctl restart xxx

还可以通过 status 查看状态:
systemctl status xxx

使用 systemctl 还有一个优势,那就是你可以在脚本使你的这个服务在挂掉后自动启动,加个配置即可:
RestartSec = 12s


以下是我在生产环境的一个系统的实际用法:
[Unit]
Description = Stock Service
After = network.target

[Service]
Type = forking
Restart = on-failure
RestartSec = 12s
WorkingDirectory = /opt/app/stock
ExecStart = /opt/app/stock/stock.sh start

[Install]
WantedBy = multi-user.target


注意一下 stock.sh 这个脚本文件,就是 jfinal-club 等等项目中的 .sh 启动脚本,唯一的不同就是里头的 java 命令要使用全路径,例如:

/opt/jdk_1.8/bin/java -Xverify:none ${JAVA_OPTS} -cp ${CP} ${MAIN_CLASS} &
而不能是: java -Xverify:none ${JAVA_OPTS} -cp ${CP} ${MAIN_CLASS} &

也就是说,主要的脚本,jfinal club 中已经帮你写好了,你只需要写 xxx.service 这个 systemctl 要求的脚本即可,这个脚本的写法非常简单,可以直接参考我上面的例子。

2025-09-05 17:36

启动都用 systemctl 管理,脚本里头可以配置依赖次序,具体问一下 GPT

2025-09-05 00:58

用 CPI : CPI.getAttrs(model);

2025-09-03 12:38

@杜福忠 那应该已薅满,aifei.cn 上线正好用上,nice

2025-09-03 02:51

已薅,一共领了四个,最多只能领四个吗?

2025-08-28 17:50

AutoTableBind 是第三方出的扩展,jfinal 官方一直没有这个,可以通过生成器自动生成,下载官方 blog 项目参考一下

2025-08-18 13:50

不要开启 fastMode 就行:
engine.setFastMode(...) 这个配置不要加,或者:engine.setFastMode(false)

2025-08-15 02:31

@shenbaise 今天还有同学正好用上了这个功能,配置一下 undertow.resourcePath 即可:

按照官方给的配置文件来配置:
https://gitee.com/jfinal/jfinal-undertow/blob/master/undertow.txt

2025-08-06 12:15

@jFinal用户0028 这个不变动项目本身,只是启动方式改一点点而已

jfinal undertow 支持所有 jfinal 版本

2025-08-05 23:27

太老了,直接换 jfinal-undertow :
https://gitee.com/jfinal/jfinal-undertow

在官网下载现成的 demo,用上里头的 po.xml 直接换掉,在 idea 下非常方便,不必折腾 eclipse:
https://jfinal.com/download/now?file=jfinal_demo_for_maven-5.0.0.zip

2025-07-15 17:19

@江yu jetty 这都多少年前的事了, jfinal undertow 可以让开发、生产一体化,省心、省时

2025-07-15 14:02

使用 jfinal-undertow,配置一下 pom.xml 即可。 我复制一份 jfinal 俱乐部在使用的配置:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>


<groupId>com.jfinal</groupId>
<artifactId>jfinal-club</artifactId>
<version>5.0.6</version>
<packaging>jar</packaging>


<name>jfinal-club</name>
<url>https://jfinal.com/club</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
</properties>

<dependencies>

<!-- jfinal -->
<dependency>
<groupId>com.jfinal</groupId>
<artifactId>jfinal</artifactId>
<version>5.0.6</version>
</dependency>

<!-- jfinal-undertow 开发、部署一体化 web 服务器 -->
<dependency>
<groupId>com.jfinal</groupId>
<artifactId>jfinal-undertow</artifactId>
<version>3.3</version>
</dependency>

<!-- cos 文件上传 -->
<dependency>
<groupId>com.jfinal</groupId>
<artifactId>cos</artifactId>
<version>2022.2</version>
</dependency>

<!-- cglib 扩展 CglibProxyFactory extends ProxyFactory -->
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib-nodep</artifactId>
<version>3.3.0</version>
</dependency>

<!-- fastjson json 转换 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.80</version>
</dependency>

<!-- 开发 WebSockets 时开启下面的依赖 -->
<!--
<dependency>
<groupId>io.undertow</groupId>
<artifactId>undertow-websockets-jsr</artifactId>
<version>2.2.17.Final</version>
</dependency>
-->

<!-- junit 单元测试 -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>

<!-- 避免控制台输出如下提示信息:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
项目中实际上用不到这个 jar 包
注意:eclipse 下可以将 scope 设置为 provided
-->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
<version>1.7.36</version>
<!-- 打包前改成 provided,此处使用 compile 仅为支持 IDEA -->
<scope>compile</scope>
</dependency>

<!-- druid 数据源连接池 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.0.29</version>
</dependency>

<!-- log4j 日志 -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>

<!-- mysql 驱动 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.49</version>
</dependency>

<!-- ehcache 缓存 -->
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-core</artifactId>
<version>2.6.11</version>
</dependency>

<!-- 邮件发送 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-email</artifactId>
<version>1.5</version>
</dependency>

<!-- jsoup 过滤恶意数据提交 -->
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.9.2</version>
</dependency>

<!-- joda-time 日期、时间变换 -->
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.9.3</version>
</dependency>

<!-- cron4j 任务调度 -->
<dependency>
<groupId>it.sauronsoftware.cron4j</groupId>
<artifactId>cron4j</artifactId>
<version>2.2.5</version>
</dependency>

<!-- zxing 二维码生成 -->
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>javase</artifactId>
<version>3.2.1</version>
</dependency>

</dependencies>


<build>
<finalName>jfinal-club</finalName>


<!--
添加 includes 配置后,excludes 默认为所有文件 **/*.*,反之亦然
该规则在 maven-jar-plugin 等插件中同样适用
-->
<resources>
<!-- 添加该配置是为了将 .sql 文件打入 jar 包 -->
<resource>
<directory>src/main/java</directory>
<includes>
<!-- **/* 前缀用法,可以匹配所有路径 -->
<include>**/*.sql</include>
<include>**/*.class</include>
</includes>
</resource>

<!--
没有添加 resources 配置时,src/main/resources 目录是默认配置
一旦添加 resources 配置指向 src/main/java 目录时,原先的默认配置被取代,
所以需要添加如下配置将默认配置再添加进来,否则无法使用 src/main/resources
下的资源文件
-->
<resource>
<directory>src/main/resources</directory>
</resource>

<!--
将 webapp 也指定为资源文件,并且将之输出到 webapp 目录下
该配置可以取代 maven-resources-plugin 的功能

targetPath: http://maven.apache.org/pom.html#Resources

注意:如果 web 资源本身就放在 src/main/resources/webapp 之下,
需要删除下面的配置
-->
<resource>
<directory>src/main/webapp</directory>
<targetPath>webapp</targetPath>
</resource>
</resources>


<plugins>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
<!-- java8 保留参数名编译参数 -->
<compilerArgument>-parameters</compilerArgument>
<compilerArguments><verbose /></compilerArguments>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<finalName>jfinal-club</finalName>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.jfinal.club.common.JFinalClubConfig</mainClass>
</transformer>

<!--
下面的配置支持排除指定文件打包到 jar 之中,可以用于排除需要修改的配置文件以便于在外部的 config 目录下的
同名配置文件生效,建议使用 Prop.appendIfExists(xxx_pro.txt) 在外部放一个非同名配置来覆盖开发环境的配置
则可以不用使用下面的配置,文档参考:
http://maven.apache.org/plugins/maven-shade-plugin/examples/resource-transformers.html#DontIncludeResourceTransformer
-->
<transformer implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer">
<resources>
<!-- <resource>jfinal-club-config-dev.txt</resource> -->
<!-- <resource>.PDF</resource> -->
<!-- <resource>READ.md</resource> -->
</resources>
</transformer>
</transformers>

<!--
解决 fatjar 的 "java.lang.SecurityException: Invalid signature file digest
for Manifest main attributes" 问题
-->
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>

</configuration>
</execution>
</executions>
</plugin>

</plugins>
</build>
</project>

2025-06-30 18:26

SqlKit 是 ActiveRecordPlugin 自己内部维护的,不需要干预

添加 sql 使用 : activeRecordPlugin.addSqlTemplate(...)