引入rundertow支持,启动项目快人一步
This commit is contained in:
parent
2d79d7ef75
commit
b1e9f70025
3
.gitignore
vendored
3
.gitignore
vendored
@ -7,4 +7,5 @@
|
|||||||
*.iml
|
*.iml
|
||||||
.idea/
|
.idea/
|
||||||
/.idea/
|
/.idea/
|
||||||
/out/
|
/out/
|
||||||
|
config.properties
|
69
jfinal.bat
Normal file
69
jfinal.bat
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
@echo off
|
||||||
|
|
||||||
|
rem -------------------------------------------------------------------------
|
||||||
|
rem
|
||||||
|
rem 使用说明:
|
||||||
|
rem
|
||||||
|
rem 1: 该脚本用于别的项目时只需要修改 MAIN_CLASS 即可运行
|
||||||
|
rem
|
||||||
|
rem 2: JAVA_OPTS 可通过 -D 传入 undertow.port 与 undertow.host 这类参数覆盖
|
||||||
|
rem 配置文件中的相同值此外还有 undertow.resourcePath, undertow.ioThreads
|
||||||
|
rem undertow.workerThreads 共五个参数可通过 -D 进行传入
|
||||||
|
rem
|
||||||
|
rem 3: JAVA_OPTS 可传入标准的 java 命令行参数,例如 -Xms256m -Xmx1024m 这类常用参数
|
||||||
|
rem
|
||||||
|
rem
|
||||||
|
rem -------------------------------------------------------------------------
|
||||||
|
|
||||||
|
setlocal & pushd
|
||||||
|
|
||||||
|
|
||||||
|
rem 启动入口类,该脚本文件用于别的项目时要改这里
|
||||||
|
set MAIN_CLASS=com.lxyer.config.FlyConfig
|
||||||
|
|
||||||
|
rem Java 命令行参数,根据需要开启下面的配置,改成自己需要的,注意等号前后不能有空格
|
||||||
|
rem set "JAVA_OPTS=-Xms256m -Xmx1024m -Dundertow.port=80 -Dundertow.host=0.0.0.0"
|
||||||
|
rem set "JAVA_OPTS=-Dundertow.port=80 -Dundertow.host=0.0.0.0"
|
||||||
|
|
||||||
|
|
||||||
|
if "%1"=="start" goto normal
|
||||||
|
if "%1"=="stop" goto normal
|
||||||
|
if "%1"=="restart" goto normal
|
||||||
|
|
||||||
|
goto error
|
||||||
|
|
||||||
|
|
||||||
|
:error
|
||||||
|
echo Usage: jfinal.bat start | stop | restart
|
||||||
|
goto :eof
|
||||||
|
|
||||||
|
|
||||||
|
:normal
|
||||||
|
if "%1"=="start" goto start
|
||||||
|
if "%1"=="stop" goto stop
|
||||||
|
if "%1"=="restart" goto restart
|
||||||
|
goto :eof
|
||||||
|
|
||||||
|
|
||||||
|
:start
|
||||||
|
set APP_BASE_PATH=%~dp0
|
||||||
|
set CP=%APP_BASE_PATH%config;%APP_BASE_PATH%lib\*
|
||||||
|
echo starting jfinal undertow
|
||||||
|
java -Xverify:none %JAVA_OPTS% -cp %CP% %MAIN_CLASS%
|
||||||
|
goto :eof
|
||||||
|
|
||||||
|
|
||||||
|
:stop
|
||||||
|
set "PATH=%JAVA_HOME%\bin;%PATH%"
|
||||||
|
echo stopping jfinal undertow
|
||||||
|
for /f "tokens=1" %%i in ('jps -l ^| find "%MAIN_CLASS%"') do ( taskkill /F /PID %%i )
|
||||||
|
goto :eof
|
||||||
|
|
||||||
|
|
||||||
|
:restart
|
||||||
|
call :stop
|
||||||
|
call :start
|
||||||
|
goto :eof
|
||||||
|
|
||||||
|
endlocal & popd
|
||||||
|
pause
|
56
jfinal.sh
Normal file
56
jfinal.sh
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# 启动入口类,该脚本文件用于别的项目时要改这里
|
||||||
|
MAIN_CLASS=com.lxyer.config.FlyConfig
|
||||||
|
|
||||||
|
COMMAND="$1"
|
||||||
|
|
||||||
|
if [[ "$COMMAND" != "start" ]] && [[ "$COMMAND" != "stop" ]] && [[ "$COMMAND" != "restart" ]]; then
|
||||||
|
echo "Usage: $0 start | stop | restart"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Java 命令行参数,根据需要开启下面的配置,改成自己需要的,注意等号前后不能有空格
|
||||||
|
# JAVA_OPTS="-Xms256m -Xmx1024m -Dundertow.port=80 -Dundertow.host=0.0.0.0"
|
||||||
|
# JAVA_OPTS="-Dundertow.port=80 -Dundertow.host=0.0.0.0"
|
||||||
|
|
||||||
|
# 生成 class path 值
|
||||||
|
APP_BASE_PATH=$(cd `dirname $0`; pwd)
|
||||||
|
CP=${APP_BASE_PATH}/config:${APP_BASE_PATH}/lib/*
|
||||||
|
|
||||||
|
function start()
|
||||||
|
{
|
||||||
|
# 运行为后台进程,并在控制台输出信息
|
||||||
|
java -Xverify:none ${JAVA_OPTS} -cp ${CP} ${MAIN_CLASS} &
|
||||||
|
|
||||||
|
# 运行为后台进程,并且不在控制台输出信息
|
||||||
|
# nohup java -Xverify:none ${JAVA_OPTS} -cp ${CP} ${MAIN_CLASS} >/dev/null 2>&1 &
|
||||||
|
|
||||||
|
# 运行为后台进程,并且将信息输出到 output.log 文件
|
||||||
|
# nohup java -Xverify:none ${JAVA_OPTS} -cp ${CP} ${MAIN_CLASS} > output.log &
|
||||||
|
|
||||||
|
# 运行为非后台进程,多用于开发阶段,快捷键 ctrl + c 可停止服务
|
||||||
|
# java -Xverify:none ${JAVA_OPTS} -cp ${CP} ${MAIN_CLASS}
|
||||||
|
}
|
||||||
|
|
||||||
|
function stop()
|
||||||
|
{
|
||||||
|
# 支持集群部署
|
||||||
|
kill `pgrep -f ${APP_BASE_PATH}` 2>/dev/null
|
||||||
|
|
||||||
|
# kill 命令不使用 -9 参数时,会回调 onStop() 方法,确定不需要此回调建议使用 -9 参数
|
||||||
|
# kill `pgrep -f ${MAIN_CLASS}` 2>/dev/null
|
||||||
|
|
||||||
|
# 以下代码与上述代码等价
|
||||||
|
# kill $(pgrep -f ${MAIN_CLASS}) 2>/dev/null
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ "$COMMAND" == "start" ]]; then
|
||||||
|
start
|
||||||
|
elif [[ "$COMMAND" == "stop" ]]; then
|
||||||
|
stop
|
||||||
|
else
|
||||||
|
stop
|
||||||
|
start
|
||||||
|
fi
|
58
package.xml
Normal file
58
package.xml
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
|
||||||
|
<!--
|
||||||
|
assembly 打包配置更多配置可参考官司方文档:
|
||||||
|
http://maven.apache.org/plugins/maven-assembly-plugin/assembly.html
|
||||||
|
-->
|
||||||
|
|
||||||
|
<id>release</id>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
设置打包格式,可同时设置多种格式,常用格式有:dir、zip、tar、tar.gz
|
||||||
|
dir 格式便于在本地测试打包结果
|
||||||
|
zip 格式便于 windows 系统下解压运行
|
||||||
|
tar、tar.gz 格式便于 linux 系统下解压运行
|
||||||
|
-->
|
||||||
|
<formats>
|
||||||
|
<format>dir</format>
|
||||||
|
<format>zip</format>
|
||||||
|
<!-- <format>tar.gz</format> -->
|
||||||
|
</formats>
|
||||||
|
|
||||||
|
<!-- 打 zip 设置为 true 会在包在存在总目录,打 dir 时设置为 false 少层目录 -->
|
||||||
|
<includeBaseDirectory>true</includeBaseDirectory>
|
||||||
|
|
||||||
|
<fileSets>
|
||||||
|
<!-- src/main/resources 全部 copy 到 config 目录下 -->
|
||||||
|
<fileSet>
|
||||||
|
<directory>${basedir}/src/main/resources</directory>
|
||||||
|
<outputDirectory>config</outputDirectory>
|
||||||
|
</fileSet>
|
||||||
|
|
||||||
|
<!-- src/main/webapp 全部 copy 到 webapp 目录下 -->
|
||||||
|
<fileSet>
|
||||||
|
<directory>${basedir}/src/main/webapp</directory>
|
||||||
|
<outputDirectory>webapp</outputDirectory>
|
||||||
|
</fileSet>
|
||||||
|
|
||||||
|
<!-- 项目根下面的脚本文件 copy 到根目录下 -->
|
||||||
|
<fileSet>
|
||||||
|
<directory>${basedir}</directory>
|
||||||
|
<outputDirectory></outputDirectory>
|
||||||
|
<!-- 脚本文件在 linux 下的权限设为 755,无需 chmod 可直接运行 -->
|
||||||
|
<fileMode>755</fileMode>
|
||||||
|
<includes>
|
||||||
|
<include>*.sh</include>
|
||||||
|
<include>*.bat</include>
|
||||||
|
</includes>
|
||||||
|
</fileSet>
|
||||||
|
</fileSets>
|
||||||
|
|
||||||
|
<!-- 依赖的 jar 包 copy 到 lib 目录下 -->
|
||||||
|
<dependencySets>
|
||||||
|
<dependencySet>
|
||||||
|
<outputDirectory>lib</outputDirectory>
|
||||||
|
</dependencySet>
|
||||||
|
</dependencySets>
|
||||||
|
</assembly>
|
57
pom.xml
57
pom.xml
@ -2,7 +2,7 @@
|
|||||||
<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">
|
<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>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<packaging>war</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>jfly</name>
|
<name>jfly</name>
|
||||||
<groupId>com.lxyer</groupId>
|
<groupId>com.lxyer</groupId>
|
||||||
@ -16,6 +16,12 @@
|
|||||||
<version>4.2</version>
|
<version>4.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.jfinal</groupId>
|
||||||
|
<artifactId>jfinal-undertow</artifactId>
|
||||||
|
<version>1.6</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>mysql</groupId>
|
<groupId>mysql</groupId>
|
||||||
<artifactId>mysql-connector-java</artifactId>
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
@ -77,6 +83,55 @@
|
|||||||
<target>1.8</target>
|
<target>1.8</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
jar 包中的配置文件优先级高于 config 目录下的 "同名文件"
|
||||||
|
因此,打包时需要排除掉 jar 包中来自 src/main/resources 目录的
|
||||||
|
配置文件,否则部署时 config 目录中的同名配置文件不会生效
|
||||||
|
-->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
|
<version>2.6</version>
|
||||||
|
<configuration>
|
||||||
|
<excludes>
|
||||||
|
<exclude>*.txt</exclude>
|
||||||
|
<exclude>*.xml</exclude>
|
||||||
|
<exclude>*.properties</exclude>
|
||||||
|
</excludes>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-assembly-plugin</artifactId>
|
||||||
|
<version>3.1.0</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>make-assembly</id>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>single</goal>
|
||||||
|
</goals>
|
||||||
|
|
||||||
|
<configuration>
|
||||||
|
<!-- 打包生成的文件名 -->
|
||||||
|
<finalName>${project.artifactId}</finalName>
|
||||||
|
<!-- jar 等压缩文件在被打包进入 zip、tar.gz 时是否压缩,设置为 false 可加快打包速度 -->
|
||||||
|
<recompressZippedFiles>false</recompressZippedFiles>
|
||||||
|
<!-- 打包生成的文件是否要追加 release.xml 中定义的 id 值 -->
|
||||||
|
<appendAssemblyId>true</appendAssemblyId>
|
||||||
|
<!-- 指向打包描述文件 package.xml -->
|
||||||
|
<descriptors>
|
||||||
|
<descriptor>package.xml</descriptor>
|
||||||
|
</descriptors>
|
||||||
|
<!-- 打包结果输出的基础目录 -->
|
||||||
|
<outputDirectory>${project.build.directory}/</outputDirectory>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ public class DbMap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void addSqlTemplate(ActiveRecordPlugin arp) {
|
public static void addSqlTemplate(ActiveRecordPlugin arp) {
|
||||||
String baseSqlTemplatePath = PathKit.getWebRootPath() + "/WEB-INF/classes/sql/";
|
String baseSqlTemplatePath = PathKit.getRootClassPath() + "/sql/";
|
||||||
arp.setBaseSqlTemplatePath("sql");
|
arp.setBaseSqlTemplatePath("sql");
|
||||||
|
|
||||||
File sqlFiles = new File(baseSqlTemplatePath);
|
File sqlFiles = new File(baseSqlTemplatePath);
|
||||||
|
@ -10,9 +10,9 @@ import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
|
|||||||
import com.jfinal.plugin.ehcache.EhCachePlugin;
|
import com.jfinal.plugin.ehcache.EhCachePlugin;
|
||||||
import com.jfinal.plugin.hikaricp.HikariCpPlugin;
|
import com.jfinal.plugin.hikaricp.HikariCpPlugin;
|
||||||
import com.jfinal.plugin.redis.RedisPlugin;
|
import com.jfinal.plugin.redis.RedisPlugin;
|
||||||
|
import com.jfinal.server.undertow.UndertowServer;
|
||||||
import com.jfinal.template.Engine;
|
import com.jfinal.template.Engine;
|
||||||
import com.lxyer.config.handler.UrlHandler;
|
import com.lxyer.config.handler.UrlHandler;
|
||||||
import com.lxyer.config.interceptor.LoginInterceptor;
|
|
||||||
import com.lxyer.config.route.AdminRoute;
|
import com.lxyer.config.route.AdminRoute;
|
||||||
import com.lxyer.config.route.SiteRoute;
|
import com.lxyer.config.route.SiteRoute;
|
||||||
|
|
||||||
@ -74,4 +74,9 @@ public class FlyConfig extends JFinalConfig {
|
|||||||
public void configHandler(Handlers me) {
|
public void configHandler(Handlers me) {
|
||||||
me.add(new UrlHandler());
|
me.add(new UrlHandler());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 启动入口
|
||||||
|
public static void main(String[] args) {
|
||||||
|
UndertowServer.start(FlyConfig.class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
1
src/main/resources/undertow.txt
Normal file
1
src/main/resources/undertow.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
MAIN_CLASS=com.lxyer.config.FlyConfig
|
Loading…
Reference in New Issue
Block a user