# jfinal-undertow
**Repository Path**: ppnt/jfinal-undertow
## Basic Information
- **Project Name**: jfinal-undertow
- **Description**: jfinal-undertow 用于开发、部署由 jfinal 开发的 web 项目。独创 HotSwapClassLoader + HotSwapWatcher 以 319 行代码极简实现热加载开发与部署,前无古人,后必有模仿者
- **Primary Language**: Java
- **License**: Apache-2.0
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 94
- **Created**: 2023-09-04
- **Last Updated**: 2023-09-04
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
## jfinal-undertow
[中文](README.md) [English](README_en.md)
#### Project Introduction
jfinal-undertow is used for the development and deployment of web projects developed by jfinal. It innovatively introduces the HotSwapClassLoader + HotSwapWatcher, achieving hot-reloading for both development and deployment with just 321 lines of code. This approach is unprecedented, and will surely inspire others to follow suit.
## I. Quick Start
### 1: Add maven dependency
```
com.jfinal
jfinal-undertow
3.5
```
Note: Remove the previous maven dependency on jetty-server.
### 2: Create a main method and launch the project in eclipse or IDEA.
```
UndertowServer.start(AppConfig.class);
```
Here, AppConfig is a subclass inherited from JFinalConfig. The previous JFinal.start(...) usage is no longer needed.
## II. Quick Packaging and Deployment
### 1: Change the packaging type in the header of pom.xml from war to jar.
```
jar
```
### 2: Add maven-jar-plugin to pom.xml.
```
org.apache.maven.plugins
maven-jar-plugin
2.6
*.*
```
This plugin is solely to prevent configuration files from being included in the jar. If packaging as a fatjar, this plugin is unnecessary.
### 3: Add maven-assembly-plugin to pom.xml.
```
org.apache.maven.plugins
maven-assembly-plugin
3.1.0
make-assembly
package
single
${project.artifactId}
false
true
package.xml
${project.build.directory}/
```
### 4: Add a packaging descriptor file, package.xml, to the project root. Contents are as follows:
```
release
dir
zip
true
${basedir}/src/main/resources
config
${basedir}/src/main/webapp
webapp
WEB-INF
WEB-INF/web.xml
${basedir}
755
unix
*.sh
${basedir}
755
windows
*.bat
lib
```
### 5: Add project run script files to the project root directory.
This project provides jfinal.sh and jfinal.bat scripts in the root directory. jfinal.sh is for Linux/Mac systems, while jfinal.bat is for Windows. Ensure to modify the MAIN_CLASS variable in these scripts to point to your project entry, e.g.:
```
MAIN_CLASS=com.yourpackage.YourMainClass
```
These script files are optional. You can write your own startup scripts based on personal preference.
### 6: Run the packaging command in the terminal.
```
mvn clean package
```
### 7: Deployment
Navigate to the project's target/your-project-release directory and run ./jfinal.sh start to launch the project. The target directory will also contain a your-project-release.zip file. This is a compressed zip file of the directory generated in the fifth step. Upload and extract this file on the server to deploy. You can modify the package.xml to change the generated filename or opt not to generate this file.
## III. Advantages of jfinal-undertow:
1: Ultra-fast startup, 5 to 8 times faster than Tomcat. The jfinal.com official website starts within 1.5 seconds.
2: A brilliantly simple hot-deployment design ensures lightning-fast and lightweight hot-reloading, enhancing the development experience.
3: Performance surpasses Tomcat and Jetty, suitable as a replacement for production environments.
4: Undertow is designed for embedding, allowing direct deployment in production environments without downloading or configuring services, making it ideal for microservices development and deployment.
5: Say goodbye to web.xml, Tomcat, and Jetty, saving a significant amount of packaging and deployment time. It makes development, packaging, and deployment a joy.
6: Feature-rich, supporting classHotSwap, WebSocket, gzip compression, servlets, filters, sessionHotSwap, and more.
7: Supports both fatjar and non-fatjar packaging modes, preparing jfinal for upcoming microservices functionality.
8: Unified development, packaging, and deployment processes. The entire workflow requires no adjustments or modifications to any part of the project, truly achieving rapid development to rapid deployment.
9: The above are just some of the features of jfinal-undertow. For more useful functionalities like the fatjar packaging mode, please refer to the official jfinal documentation.